57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 16 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.
Argh. Those explicit slices are really unpythonic. Please use split.
Also, see dict.setdefault. ;-)
More
Inspired by algorithmically beautiful and Pythonically ugly @quiath's [solution](http://www.checkio.org/mission/the-square-chest/publications/quiath/python-3/nice-and-simple/?ordering=most_voted).
There is only _one_ place where 4 is mentioned in the code, and changing it enables the algorithm to w
More
Lines 2-5: do you know what "precondition" means? :-/
Line 6: data.sort() is more readable and faster.
Line 11: I don't get why you float m. Of course you don't need to.
Lines 15-19: This is really head-scratching. Why do you do such contortions??
More
That inner while loop, with explicit x management, is unnecessary.
for letter, lnext in zip(word, word[1:]):
(you might want to end the zip earlier if your snake is too young:).
More
First, it's not advisable to change (line 39) a dict iterated through (line 33).
Second, why line 42? If not x, then surely second not in x. :-)
More
Argh, famous [FOR-CASE paradigm](https://en.wikipedia.org/wiki/Loop-switch_sequence). :-O
More
Please use // instead of int(.../...).
Also, that len(list) // 2 could be named some nice name. ;-)
More
Lines 11~15: Please learn about tuple comparisons. They are really helpful here.
(a, b) < (c, d) means exactly a < c or a == c and b < d.
More
sum being a builtin means you should use it as a builtin, not redefine it. :-)
Also, please iterate through sequence, not indices. Learn about slices if you need only some indices.
More
Nice and obvious. Hint: you don't need line 4, "for word in words.split()" would work just as nicely (.split would be evaluated only once:).
More
OK, but you might want to learn about sets and & (intersection) operator. Faster and cleaner than rolling your own.
More
The most pointless use of yield from. :-)
BTW, line 7 could probably be array.pop(argmax). At least if you say array = list(initial) in line 2.
More