35
Фёдор Кузнецов
Last seen 11 months ago
Member for 5 years, 11 months, 2 days
Difficulty Normal
Just a student from Russia. Started learn python on Checkio.
You could replace the expression in a line 4:
not (y < 20 or y > 40)
in another
20 <= y <= 40
On example:
first = lambda y: not(y<20 or y>40)
second = lambda y: 20<=y<=40
all(first(x) == second(x) for x in range(100)) # True
More
Next time just use `text.lower().split()` instead `text.lower().replace('\n', ' ').split(' ')`
More
It's cool! But this method will not work in missions, where warrior have attack=0. Although I think you know this and you have a way to fix it)
More
If I understood your decision correctly, you could use `for deckI in range(min(hand), deck)` in line 5, or is it not?
More
Short and readable, but so many time for tests with a large date interval.
Please view [this solution and comments](https://py.checkio.org/mission/weekend-counter/publications/Merzix/python-3/with-cycle-from-itertools/)
More
You pass two parameters to the `add_units` method. `_type` is a type of warrior. `_type()` creates an instance of the class. At this stage it is `Warrior` or `Knight`. In the future may be `Healer`, `Vampire` and others. I did not want to use the reserved name `type`, so I changed it to `_type`.
More
For tests with a large date interval this solution waste very much time. On example
checkio(date(13, 9, 18), date(2013, 9, 23))
average lead time 1.25 seconds
More
What does the expression in the last line do?
{:0>2}
Is this a slice of the string minutes? How it works?
More
Why not just equate methods?
def __gt__(self, other):
return True
__ne__ = __le__ = __eq__ = __lt__ = __ge__ = __gt__
Or use lambda-functions?
More
It's not principial, but you can use `join` with generator, you do not have to create a list and pass it to join.
More
Nice, but you often use the same algorithm check winner. Why not define function `checker` and use it?
def checker(cells):
if len(set(cells)) == 1 and cells[0] != '.':
return cells[0]
for row in game_result:
if checker(row):
return row[0]
etc.
More
if self._birth_date[:-4] == '01.01.':
return 2018 - int(self._birth_date[-4:])
else:
return 2018 - int(self._birth_date[-4:]) - 1
Can be replaced to:
return 2018 - int(self._birth_date[-4:]) - self._birth_date[:-4] == "01.01."
Or just `2018 - 1` can be replaced to `201
More
issubclass(bool, int) == True
x = 1
x += True
x == 2 # True
So you can use:
counter += all("condition" for ... in expression)
instead
counter += all(1 if "condition" else 0 for ... in expression)
More