57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 19 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
"square" is a very strange name for list of functions, don't you think? :-O
More
Of course, another view at the [current top solution](http://www.checkio.org/mission/striped-words/publications/RRRQ/python-3/first/).
More
Different operators can be chained, too:
if res[0][0] == res[1][0] == res[2][0] != '.':
Also, as you see, renaming your argument does wonders for readability. ;-]
More
Finally someone who used groupby correctly. :-D
You seem to have big problems with your iterators, since you're always trying to cram them into expressions. And map is not a panacea. :-)
daily_secs = ((int(r[2]) for r in records) for records in daily_records)
Or something like that. :-)
But
More
Basic idea is ok, but you have really too many cases, and (as a consequence of that) much duplication of code.
An independent objection: indices are not really very semantic when describing your values. As I already said, naming is important.
hundreds, tens, ones = map(int, str(number).zfill(3
More
Doesn't this duplication bother you? :-)
Also, `def min(*args, key=lambda x:x):`.
And saving one line just to assign min_item to min_item is not a gain. Rather bite the bullet and write `if key(item) < key(min_item): min_item = item` in one line if you really don't want to use another line.
More
What's the contest: how to write it using a maximal number of lines? :-D
More
That's a very weird way of checking whether the array is empty. :-) Of
course, the most Pythonic is simply "if not array:".
More
"sum" is a builtin. That should give you a hint. ;-)
Also, don't iterate through indices if you can iterate through elements themselves. ;-]
And, don't compare len with 0.
More
Either use `bin` sliced from 2, or use format as G-d intended.
for pin in format(first, 'b'):
Also, `int.bit_length` method might come handy. ;-)
--
G-d means Guido, of course. :-)
More
If superior is local, getgain surely should have been local too. Then it wouldn't need enemy as parameter, same as superior doesn't need numsp and sumsp as parameters.
repeat and chain.from_iterable, wonders from itertools. But might it be better to use collection.Counter, with its .most_common?
`
More
Lines 4~7: Again, don't know about Py2, but you probably have .partition. Use that instead of .split, it fits much better.
cmd, _, arg = i.partition(" ")
For the other try (lines 8, 11 and 12): Yes, EAFP is nice, but sometimes it pays to be practical:
if cmd == "POP" and stack: stack.pop(
More
Well, you said everything about ghastliness... so I won't go there. I'll just say that number of cases being finite is not an excuse to go haphazardly enumerating them. :-)
But a more important lesson about how Python namespacing works: you `import` _names_, not objects. Conclusion: you don't need
More
When using parallel iteration, try zip. Much simpler than range and a forest of brackets. :-)
Also, `message +=` and `return ''.join(message)` directly.
More
Why do you extend the answer instead of just defining the answer? :-)
answer = [0, 0, 0]
else:
answer = [ ... ]
Also, in same style, you don't need line 3. Python doesn't have declarations of variables, it has names for its objects.
More
Yeah, you should. :-D For start, study for-else loop. Much better than this insane flag manipulation.
More
Yup, something like that. But that quadrance calculation should really be factored out. At least see `math.hypot`.
More