36
Nikos Papaspyrou
https://www.softlab.ntua.gr/~nickie/
Last seen 11 months ago
Member for 10 years, 7 months, 24 days
Difficulty Normal
Almost identical, except for the list equality; I used "all", which may save you the trouble from generating the whole LHS. Well done!
More
Well done!
Just a comment: this solution is O(N\*log(N)+N\*W) where W is the maximum width of the buildings. IFAIK, there are two types of better solutions (but more complicated, unless Veky surprises us again):
1. O(N^2), using a pretty straightforward vertical scan line.
2. O(N*log(N)),
More
What I'd have in a professional solution would be memoization for the results of "possible\_values", or even better dynamic programming. For those who do not understand what I mean, consider how many times possible_values("33") will be called during checkio("593347"). If the string becomes larger,
More
About your "pad" function, lines 4 to 12, a nice trick that I learned here is that you can get away with padding your matrix only to the right and bottom, i.e. (if you do it in-situ)
def pad(m):
m.append([0]*len(m))
for row in m: row.append(0)
This works in Python because
More
Clear and correct. The drawback is that it can use too many steps to get to the ore.
More
This solution works by translating dot numbers to coordinates. In this way, it first finds the set of edges. Then, it exhaustively counts how many of all the possible squares (of increasing size) are present in the set of edges.
This is painfully slow. If the size of the grid is N, this is O(N^
More
This solution was fixed; it had a stupid bug pointed out by Bryukh. Take a look at the [new one](http://www.checkio.org/mission/painting-wall/publications/nickie/python-3/fixed-sort-and-search/), if you want.
More
This solution takes O(N\*M), where N is the length of text and M is the total length of all words. I believe this can be improved to O(N+M).
More
The "break else break" part merits [some further study](http://docs.python.org/3/reference/compound_stmts.html#the-for-statement) if you don't know that Python has an else clause for loops (as I didn't). Until then, I thought that somebody hacked Veky's account and published this puzzle for him. A
More
Why do I have the feeling that if you remove lines 4 and 5 nothing will change? Is this a puzzle after all? :-)
More