27
Last seen 2 months ago
Member for 10 years, 3 months, 26 days
Difficulty Normal
Slices are slow :(
Shorter and faster with same ideas:
checkio=c=lambda d:d.pop()+c(d)if d else 0
More
Chain of comparison looks more pythonic ;)
if not dice_number <= target <= dice_number * sides:
More
Counter() instead defaultdict(int) - it's right!
By the way, someone calculate daily bill so:
max(t, t * 2 - 100)
It looks awfull if replace "t" by "min" :)
More
if stackList!=[]: # no!
if stackList: # any iterable returns False if empty
More
Look at my way to keep leading/final sapces and to divide long words:
http://www.checkio.org/mission/cowsay/publications/blabaster/python-3/second/
More
To chase the reflection - perfect.
Final checks sometimes fails:
while True:
assert checker(hunt, ('.....X..',
'.X.XXX..',
'....X...',
'.X.XXX..',
'..X..X..',
More
if len(j & i) > 0: # no
if j & i:
For sequences, (strings, lists, tuples),
use the fact that empty sequences are false. /PEP 8/
More
Hmm, pep8-checker? Unfortunately, it can't help with
epsilon = 10 ** (-3) # no!
epsilon = 1e-3
More
>>> False == 0
True
>>> True == 1
True
so line№16 looks excessive
More
> # 21 times was enough to pass all test cases.
I say, n1 + n2 times enough ;) rolls with no change (n1, n2) you can discard.
More
elif i == "POP" and len(A): sum+=A.pop()
elif len(A): sum+= A[-1]
Add a bit of elegance:
else:
if A:
sum += A.pop() if i == "POP" else A[-1]
and name var as a "sum" is a bad practice :(
More
... explicit is better than implicit ...
It's a Hell:
self.connections = set()
for con in connections:
self.add(con)
How to relate self and self.connections?
I urge python's guru.
More
gun = tuple(
tuple(map(int, s)) for s in
('000000000000000000000000100000000000',
'000000000000000000000010100000000000',
'000000000000110000001100000000000011',
'000000000001000100001100000000000011',
'110000000010000010001100000000000000',
'11000000001000101100
More
# line №5:
grid = list(map(list, crossword))
# lines №№133..138:
return tuple(map(''.join, grid))
# It's a python ;)
More
... functions and method calls are expensive (more so than in C or Java) ... /by Guido/
More
((1,2),(2,1))[row%2][col%2]
Too heavy for my mind
(rown + coln) % 2 + 1
:=))
More