39
CDG.Axel
18 36 55 Leader of the month
9398/ 9695
Axel
Last seen 2 months ago
Member for 2 years, 9 months, 8 days
Difficulty Normal
Best reviews / Newest reviews
First-alexvbodrov
try to use sort functions with tuple of count and index something like this - only one line return sorted(items, key=lambda x: (items.count(x), -items.index(x)), reverse=True) More
8 lines proc-CDG.Axel 1
It's improvement of my [previous solution](https://py.checkio.org/mission/calculator-i/publications/CDG.Axel/python-3/10-lines-proc-simple/) More
Complex nails-StefanPochmann
Another idea: from collections import Counter from itertools import product as prod def automaton(step: int) -> int: Z, D, R = {0}, (1, -1, 1j, -1j, 1-1j, 1j-1), range(step - 1) [Z.update({z for z, c in Counter(map(sum, prod(Z, D))).items() if c == 1}) for _ in R] More
2 lines proc-CDG.Axel
alternative solution with sets (4 symbols longer - new expression inside 'sum') sum(i.weekday() < 5 for i in set(ds + dt.timedelta(i) for i in range(1 + (de - ds).days)) - set(holy)) More
First-vasily_bortnikov
too heavy for "elementary" task :) More
First-rjuanjp98
It's not necessary to use list[str]: vowels = ["a","e","i","o","u","y"] return character in vowels --> vowels = "aeiouy" return character in vowels In addition you can slightly this 6 lines: if current_character != " ": if is_vowel(current_character): More
First-rjuanjp98
It's not necessary to use list-comprehension instead of a generator. And you can use standard 'filter' function for zero removing (with None as first argument): sorted_list = sorted([x for x in items if x != 0]) --> sorted_list = sorted(x for x in items if x != 0) --> so More
First-ah.ouggadi
Good way to illustrate EAFP (Easy Ask Forgiveness than Permission) :) But index variable isn't necessary... More
First-shoikan
Great! But it's slightly shorter: return items[items.index(border) if border in items else 0:] More
First-Ygorchist
There is good function groupby in itertools. It helps shorten solution to one line More
Second-dygger 1
you can replace "sum(1 for _ in g)" with "len(list(g))" More
First-rjuanjp98
Wow, it looks... PEP unfriednly :) First, integer division "//" better than math.floor() and math.ceil(). Plus == 1 in condition is useless: math.floor(len(data)/2) --> len(data) // 2 math.ceil(len(data)/2) --> (len(data) + 1) // 2 return ... if len(data) % 2 == 1 el More
rem prefix-amvasiliev80
Length difference of original and rstriped string is slightly shorter More
all before + set-Kosya
great! but sum(map(str.isdigit, password)) is slightly shorter than sum([i.isdigit() for i in password]) More
First-Kosya
you can use map text with str.isdigit and sum results to avoid c-like cycles More
Pangram-dnkomaroff
you can use “return condition” instead “return True if condition else False” return not len(set(string.ascii_lowercase) - set(text.lower())) More
First-olevoniuk
Interesting possibility, but looks not clear More
First-Alejandro_El_Diablo
it looks like C++ code ) if can use something like this res = ['_' + i.lower() if i.isupper() else i for i in name] More
split-Olpag 1
map(str.strip, a.splitlines()) map(str.strip,i.split(':')) looks sligtly shorter than [i.strip() for i in a.split('\n') if i] (i.strip() for i in elem.split(':')) More
First-m.mit.zf
for first line you can use "sorted" and filter with first argument None to avoid cycle: l = sorted(filter(None, items)) last line looks slightly better with some editions: return [l.pop(0) if i else 0 for i in items] PS: used pop(0) to avoid reverse sorting More
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18
19 20 21 22 23 24 25 26 27 28 29 30 31