57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 14 hours ago
Member for 11 years, 6 months, 24 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.
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
[Stolen.](http://www.checkio.org/mission/three-words/publications/veky/python-3/for-else/) ;-)
More
ROTFL. :-D
For fun to be complete, you could have used my "slice twice" technique:
l[i-3:i] ~~ l[:i][-3:]
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
Using not with 2 branches is usually frowned upon. It's better to reverse branches and eliminate not:
if array:
return sum ...
return 0
Even better is to use try. But you're probably too young for that. :-)
More
"if int(digit)" is enough.
Or better, to remove duplications of int(...):
for digit in map(int, str(number)):
if digit:
mal *= digit
(You can even use filter(None,...) but let's not go there.:)
BTW what's "mal" (as a name)?
More
Same as before:
if args:
return max ...
return 0
In new Pythons, you can use default=0 in min and max.
More
Nice "oneliner". :-P But why all those list(...)s? [] are enough.
And sum([a,b,a]) is really nicer written as 2*a+b.
More
Why a list?? You never do anything with it except append 1, increment some element (pointless) and return len.
More