39
CDG.Axel
18 36 55 Leader of the month
9398/ 9695
Axel
Last seen 1 month ago
Member for 2 years, 8 months, 21 days
Difficulty Normal
Best reviews / Newest reviews
First-dig 4 2
Optimization ideas: --> # first step: removed List (used once), space as argument of split(), and useless condition counter=0 for word in text.split(): if word.isdigit(): counter += int(word) return counter --> # next step - comprehension with if More
Reverse String (second)-tssrkt777 3 1
best way to reverse string, imo :) More
Walrus :)-suic 3
you need no walrus and if-comprehension: return sum( max(0 ,(min(d2, end_watching or d2) - max(d1, start_watching or d1)).total_seconds()) for d1, d2 in zip_longest(*[iter(els)] * 2, fillvalue=end_watching) and zip_longest too: for d1, d2 in zip(els[::2], els[1::2] + [ More
Remove All Before-tssrkt777 2 1
Great! Btw... return items[items.index(border) if border in items else 0:] More
All the Same-tssrkt777 2 1
You can remove elements==[] modifying condition) More
The Defenders-tssrkt777 2 1
Можно попробовать сделать для воина функцию make_hit(self, target), и пихнуть туда всю логику удара. при этом хорошим решеним будет пихнуть вынести defense на уровень базового класса. Таким образом можно сократить функцию fight(attacker, defender) для двух воинов вообще до 3 строк. Ну или до 4х, есл More
First-Sebdidier 2 1
a slightly longer in symbols than with zip, but faster return sum([(b - a).total_seconds() for a, b in zip(els[::2], els[1::2])]) More
First-nomis517 2
code will be faster if replace sum with len More
Correct Sentence-tssrkt777 2 1
Looks like the shortest solution! More
Replace First-tssrkt777 2 1
Slices are good, but slices without if better ) return items[1:] + items[:1] More
4th while and try-amvasiliev80 2
Interesting 'except IndexError' application! Better than use 'I love python' task for it :) More
Backward Each Word-tssrkt777 2 1
It's not necessary to use regular expressions. Another one-line solution: 1. split the text with split(' ') 2. reverse each string with slice 3. combine parts back with ' '.join() More
Absolute Sorting-tssrkt777 2 1
Good, but you need no 'lambda' there :) More
Morse Decoder-tssrkt777 2 1
И опять слишком похоже на C++ :) Есть несколько хитростей, чтобы сократить функцию до одной строчки 1. Добавьте в MORSE такое значение - "": "*", и посмотрите, во что превратится code.split(' '). Это позволит вам избавиться от цикла по словам. 2. Используйте comprehension вместо внутреннего цикла ( More
The Warriors-tssrkt777 2 1
Для для is_alive можно использовать декоратор \@property. Уберет кучу строчек кода (минимум 4) @property def is_alive(self): return self.health > 0 More
Split List-tssrkt777 2 1
Слишком много лишнего. Не бойтесь заставить программу поработать, когда не так страшно время выполнения. Например первое условие (if items==[]) можно убрать, и ничего не изменится Далее, страшное сравнение можно сильно упростить вот так: x := (len(items) + 1) // 2 Ну и наконец в питоне 3.8 в More
Split Pairs-tssrkt777 2 1
Shortest code with no re.findall :) More
2 Solutions in 1-Alex_4444D 2
Very familiar solution in comments :) My last version is 5 lines only... More
Just isupper()-paf 2 1
Constructions like 'True if condition1 else condition2' looks strange, and may be replaced with 'condition1 or condition2' return True if not text.replace(' ', '').isalpha() else text.isupper() --> return not text.replace(' ', '').isalpha() or text.isupper() Btw for this task you can s More
Shame on me for the previous one-belka-fiz 2 1
Это решение точно смотрится лучше предыдущего. Но тоже есть что поправить :) Для начала хотя бы так: datetime(1970, 1, 1, 0, 0, 0) --> datetime.max datetime(9999, 12, 31, 23, 59, 59)) --> datetime.max Далее, раз вы уже используете цикл по zip, прямо напрашивается сделать так: i More