27
dan_rue
7 24 34
3999/ 4195
Last seen 8 hours ago
Member for 1 year, 6 months, 15 days
Difficulty Normal
Best reviews / Newest reviews
First-freeman_lex 1
Thanks for that solution. I didn't know you could flatten lists/sets like that. sum(matrix, tuple()) More
First-Kurush 1
Yeah, thats the good stuff! I would give you points for it, but sadly that doesn't work in 'random soulution'.. ;) More
sum divisors == 2 * ...-Phil15 1 1
Oh wow, now THIS one is quick :D Takes 0.00 seconds for 1000 runs of is_perfect(100000000). Mine takes 0.40 seconds.. Nice one! More
Forth-freeman_lex 1
It's very slow though.. Takes over 4 seconds for n == 100'000'000 on my computer. You could at least go for divisors = filter(lambda x: n % x == 0, range(1, (n + 2) // 2)) More
find_divisors function-H0r4c3 1
it's pretty slow though.. Takes 2.5 seconds on my computer for is_perfect(100000000). You could at least go for def is_perfect(n: int) -> bool: def find_divisors(m): for i in range(1, (m + 2) // 2): if m % i == 0: yield i return sum(find_divisors(n)) More
4 lines less but weird-CDG.Axel 1 1
Loved your "Clear" solution, but now this is just a nightmare! ;) More
1liner-U.V 1 1
I think there is no need to create a list More
Make it shorter (commented)!-CDG.Axel 1
Loved this one! Lots of things to learn here. code[i] or '0' Nice! '01'[i in rs] Very nice! :) More
good task for re-lxf42 1 1
No need for those len()'s :D import re def checkio(expression): s = re.sub(r'[^\][(){}]', '', expression) n = 1 while s and n: s, n = re.subn(r'\[]|\(\)|{}', '', s) return s == '' More
Replace with whitespace in string with only brackets-Wartem 1
I like the logic, but I think you could make it more compact def checkio(exp): # From the input exp, create a new string with only the brackets allowed in it. b_in_exp = ''.join(c for c in exp if c in '()[]{}') # Replace all brackets in the new string with empty strings. Retur More
Fixed?-StefanPochmann 1 1
Very nice! Thanks for reminding me that map can take more than one iterable. More
First-donlekout
No need for the list comprehensions and the len :) return max(args) - min(args) if args else 0 More
First-kazuki.h
Nice one. Didn't know min and max have a default argument.. Now I know :D More
First-imloafer
No need for line 2 :) just return max(args) - min(args) if args else 0 More
First-mrbigrocker 1
if s2[0] >s1[0]+s1[2] or s2[0] < s1[0]: if s2[1] > s1[1]+s1[2] or s2[1]s1[0]+s1[2] or s2[0] < s1[0]) and (s2[1] > s1[1]+s1[2] or s2[1]More
First-Zhu_Xinyun 1
if s2[0]<=s1[0]+s1[2] and s2[0]>=s1[0]-s2[2]: return True else: return False could be return s2[0]<=s1[0]+s1[2] and s2[0]>=s1[0]-s2[2] More
why walk if you can ride-dx2-66
That's a nice usage of the compress function! More
First-Polundra
This code could need some cleanups.. For example, all the print statements are redundant. You could replace the 'items[len(items)-1]'-like statements with just 'items[-1]. More
itertools.combinations_with_replacement(iterable, r)-David_Jones
I have some issues with this solution.. In combinations_with_replacement you take range(1, 18) -> 1 to 17, but max(die) is <= 18. Also, you could optimize that to range(1, min(19, sum(enemy_die) - len(enemy_die) + 2) More
First-solnischka78
No need for an 'else' clause: from collections.abc import Iterable def duplicate_zeros(donuts: list[int]) -> Iterable[int]: res = [] for x in donuts: res.append(x) if x == 0: res.append(x) return res More
1
2