57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 3 hours ago
Member for 11 years, 6 months, 7 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.
Nice and OO, but really too complicated. make_track is all you really need as a separate function, and even it is too verbose. At a first glance I'd say you come from Java, but you know Python idioms very well. Only a few details I find itchy. In Lantern.move, you really could have
self.cell =
More
Aaaargh. Too complicated for my poor eyes. :-/ "== True", why? And Lines 10~11, why not just [i]? And why not use a real dict, with setdefault instead of that checking all the time?
Or better yet, just use a collections.Counter. Or even better, use builtin max with custom key. ;-P
Detail: at the e
More
letter.isupper() is what you're looking for. ;-)
Also, don't use Schlemiel the Painter's algorithm without understanding. :-]
More
Instead of rebinding words, probably inlining would be better:
for word in words.split():
This way it's obvious what you're iterating through.
More
You don't need list. sorted takes a set without problems.
And if you use .intersection, you don't need second set. .intersection takes list without problems.
Of course, probably better is to use set(...) & set(...). Or better yet, write a function for left and right side at one place.
More
len(blah) == 0 ~~~> not blah
Instead of '{([' and '})]', it would be better to use pairs,keys() and pairs.values(). That way you have a single source of truth, and don't have to think about modifying code in many places if you add a new pair.
More
Try getting used to // for int division. It will help you when you switch to Python3. ;-)
(len(data)-1)/2 ~~~> len(data) // 2
float is unnecessary if you float your 2: just say / 2.0 .
More
Again, "answer" is completely superfluous. Just return what you want instead of naming it answer.
Line 3: if number % 3 == number % 5 == 0:
More
Aargh.
I_will_return = answer
now_I_really_should_return_what = I_will_return
its_time_to_return =
...
Just return it, man. :-D
More
Don't single-exit your functions forcefully. Instead of naming it "answer", just return it.
Also, "is not None" is unnecessary. Matches are always true if anything is matched.
"and" is useful protocol, much clearer than nesting ifs. ;-)
<= 64 is unneeded.
More
You used list() seven times. _None_ of them was necessary. This must be some kind of a record. ;-P
bin(n)[2:] is nicer written as format(n, "b").
Padding with zeros is common operation. See str.zfill. (And max is also nice.;)
In any case you don't need _three_ cases. Just two. [0]*(a-a)+l is l.
More
Argh, too complicated. Have you thought about a nicer data structure than the sequence of strings? :-o
And what do you think line 4 is doing? :-/
You don't need () after while.
else in line 18 doesn't do what you probably think it does.
Line 10: if not route:
More
It's nice you learned to use "in", but you can do better.
if i.startswith("POP"): ...
More
h, m = map(int, time.split(":"))
Also, wouldn't it be nicer to name the subexpression abs(long(e?) - short)?
More
LOL. You manage to complicate everything. :-)
Line 13: just return i, no need to break first.
"if fib[0] == i: fib = [sum(fib), i]" is really funny. :-)
More