34
Last seen 2 years ago
Member for 11 years, 6 months, 11 days
Difficulty Normal
That's a nice solution! Just one niptick, no need to cast output to `list` ;-)
More
Such exotic lib with use of recent RecursionError, I bet this solution is Veky's!
Nice union-find algorithm, although handling cycles by exceeding max depth recursion limit seems a bit inefficient (and wrong on very big graph - 1000 edges, isn't it? - but I don't hope such big tests at CheckIO :-P)
More
Do you know that Python has [complex number](https://en.wikipedia.org/wiki/Complex_numberg) support?
They are often you to represent a grid in 2D, so `x + 1j * y` represents a point at coordinates _(x, y)_.
There is a trick with the second line: `[1j ** k for k in range(4)] produces [1, 1j, -1, -
More
It has been quite a while you posted this solution, and I never saw it until now.
No counter, no branch, I like it! :D
More
I definitely like the representation you have made, keeping stack and moves in same list; even better with the use of `slice`.
However, I can't tell I'm fond of this list/''.join step on tuples. If you wanted to introduce some performance with the use of `deque`, I have the feeling that looping two
More
Easier: the most frequent day is always the first day of the year.
Second day of the year has the same frequency than the first one when its year is leap.
More
Changing the beginning of the year is a nice idea.
Maybe extracting a function to compute days would be nicer:
def days_diff(date1, date2):
def days(date):
y, m, d = date
correction = m <= 2
y -= correction; m += 12*correction - 3
More
[Mine](http://www.checkio.org/mission/flatten-list/publications/DiZ/python-27/50/) is shorter, mine is shorter! :-P
More
I think your code can be clearer if instead of
if ord(cstring[i+3]) in range(48, 58):
you use
if cstring[i+3].isdigit():
More
I'm surprised, finally we have different solutions but (nearly :-P) same code length!
More
Nice approach. I feared no one else used Bellman-Ford, you proved me wrong ;-)
More
Maybe simply using Python chained assignments
__eq__ = __ne__ = __gt__ = __lt__ = __ge__ = __le__ = lambda a, b: True
More
Why not use strings for _ranks_ and _suits_? String is also iterable.
ranks, suits = '023456789TJQKA', '0scdh'
You can also write your _hand_ variable like this:
hand = {h: 10 ** n for n, h in enumerate(['0', 'HC', 'OP', 'TP', 'TK', 'St', 'Fl', 'FH', 'FK', 'SF'])}
Or even nicer:
han
More
Better than recalculate heuristic, you can simply use _cost_ and add right speed:
new_cost = cost + 2 / speed + (field_map[j][i] == 'B')
More
Can you explain a bit deduction part from (1) and (2)? I'm really interested in.
More
Better than first one, really more readable!
But still a niptick: imagine you have 2 live cells (0,0) and (100, 100).
Are you really gonna loop through 10,000 (-2) dead cells for nothing?
More