33
dig Pons
Last seen 1 month ago
Member for 2 years, 1 month, 22 days
Difficulty Easy
Looking for a code job... just because it is a hobby for me :)
If interested: trucbalear@gmail.com
First OOP in checkio or first OOP ever? Because you seem to be comfortable with objects!
More
wow!very creative the way you used to solve it with the dict :) Also very smart when using try except to avoid more code
More
Since there is too many (but easy) instructions, maybe would be fine to simplify some instructions like
if not c:
c, t = '', ''
elif c > 0:
t = ' + '
elif c < 0:
c, t = abs(c), ' - '
to
c = '' if not c else abs(c)
t = '' if not c else ' + ' if c >
More
Nothing to say! Only, maybe a bit more elegant to write
if not any(horses):
raise ValueError
instead of
if horses == [[]]:
raise ValueError
but just for comment something ;)
More
I don't know why I couldn't manage with this task in a simple way... At the beginning sounds easier than as it is when you do it
More
Are not the same nums = {*args} and nums = {args}? I thought also you could not work in the first way
More
Why do you use text.replace? In this case it would not pass "it is a cone" with second argument {cone, one}
More
Very well resoluted and very clear! Maybe you could have joined first 2 lines which are after the "for" in one using set: len(set(game_result[i])) == 1 and '.' not in...
More
Using text.find(begin) you would have had the index of begin without needing indexes (so you use index_begin+len(begin) or something like that). But yeah, actually it is a very nice code!
More
Much more simpler than mine ;)
Here I write you how I would have coded it using the same idea you had:
def checkio(n, m):
bin_n, bin_m = bin(n)[2:], bin(m)[2:]
len_diff = abs(len(bin_n) - len(bin_m))
bin_m = '0'*len_diff + bin_m
return sum(1 for i, j in zip(bi
More
You solved much shorter as I did when I did it! Today I know (maybe you too) a way to transpose a matrix so you can sum colums in a easy way as rows:
transpose_matrix = zip(*matrix)
More
Nice use of num//10 which is always true (or not false) when is not zero! Neve used un your way ;)
More
I tested for myself the difference between working with lists or strings in this task and seems to be approximately 2 times faster bc you create new strings when working with indexes like [1:]
Actually it is more elegant yours, but if you need some more efficiently, something like this would work a
More