40
suic
16 39 57
9963/ 10664
Last seen 6 days ago
Member for 9 years, 10 months, 13 days
Difficulty Advanced
Best reviews / Newest reviews
First-MaikSchoepe 8
Hi, I like you solution except from it's repetitive nature, which you can avoid: base = "I"*data rs = (("I"*5, "V"), ("V"*2, "X"), ("X"*5, "L"), ("L"*2, "C"), ("C"*5, "D"), ("D"*2, "M"), ("DCCCC", "CM"), ("CCCC", "CD"), More
Stressful Regex-narimiran 6 2
Hi, two comments: 1. You could "precompile" the regexes and used the compiled version in `re.search`. 2. Instead of `(c for c in word)` you could write `iter()`. ```python import re def is_stressful(subj): matchers = [ re.compile('+[.!-]*'.join(iter(word)), re.I) for word in More
my own ugly code, publish it to supervise myself-Akemi_Homura 4 4
Hi, you could clean it up a bit. E. g.: 1. Remove the print statements 2. int(a, 10) == int(a) so you can omit the ", 10" 3. Try to look at [this](https://docs.python.org/2/library/stdtypes.html#truth-value-testing). # Because [] == False == 0: if stack != []: == if stack: if sta More
2-liner: verify me-przemyslaw.daniel 2
Hi, nice one. You can write it like this: ```python verify_anagrams = lambda *a: list.__eq__(*map(f, a)) # or this from operator import eq ... verify_anagrams = lambda *a: eq(*map(f, a)) ``` Regards, suic More
True mathematics-ermichin158 2
Hi, you could write `return sorted([A, B, C])`. More
First-Elenka79 2
Hi, I have some comments: 1. __str__ is not a good name as [__str__](https://docs.python.org/2/library/functions.html#str) is a built-in python class 2. Instead of defining str variable and checking s in str you could use the islower() method the __str__ class. Check help(str.islower). More
They don't did it! =(-ermichin158 2
Hi, one of the most important and powerful feature of Python is `in`: for word in words: now = 0; word = word.lower(); wordLength = len(word); while now < textLength - wordLength: if text[now:wordLength+now] == word: count+=1; More
Super Simple Regex Solution-AaronCritchley 2 1
Hi, you can do it without _re_. [_filter()_](https://docs.python.org/3/library/functions.html?highlight=filter#filter) is perfect for this: return "".join(filter(str.isupper, text)) More
Typecasting Basics-atheos 2 2
Hi, few things: 1. Commenting obvious things isn't a good practice. 2. `str` is iterable so there's no need to convert it to `list`. 3. `1` is the [identity element](https://en.wikipedia.org/wiki/Identity_element) of multiplication. (see below) 4. Look at `functools.reduce`. Regards, suic ```pyt More
First-yarmak_vladislav 1
Hi, there's three time the same pattern on line 7, try to replace this: [acos((a**2 + c**2 - b**2)/(2*a*c)), acos((b**2 + c**2 - a**2)/(2*b*c)), acos((a**2 + b**2 - c**2)/(2*a*b))]] with list comprehension. More
First-CraigFranklin 1
Hi, let me have some comments: You don't need: 1. the else branches at all. 2. "== True" as test is a bool. 3. the test variable as you can use any as a condition. 4. letts as you can use data instead. 5. the parentheses on lines 5-7. After this basic cleanup your code looks like this: def c More
One line method-titaneric 1 1
Hi, look at [extended slices](https://docs.python.org/2/whatsnew/2.3.html#extended-slices): ```python array[::2] # is the same as [num for i, num in enumerate(array) if i % 2 == 0] ``` Regards, suic More
Cheater-JanKaifer 1
Hi, that `if` is redundant: return (pattern, command) in [(42,"12a0b3e4"), ...] More
First-mariacl 1
Hi, you can shorten your code like this: def checkio(data): data.sort() length = len(data) if length%2 == 0: return (data[int((length/2)-1)] + data[int(length/2)])/2 else: return data[int((length-1)/2)] More
Hacker-JanKaifer 1 1
Hi, use dictionary for this type of cheating :) More
First-EvanRavenelle 1 1
Hi, 1. lines 9, 11 are redundant. _filter()_ and Counter() can do the job for you. 2. You can replace line 13-15 with a generator expression. def checkio(text): d = Counter(filter(str.isalpha, text.lower())) return min(t for t in d if d[t] >= d[max(d, key=d.get)])[0] More
BFS tree-titaneric 1 1
Hi, 1. `list` isn't a good object good object for representing queues as `lst.pop(0)` is `O(n)` (see [this](https://wiki.python.org/moin/TimeComplexity)). You can use `collections.deque` instead. 2. There are dictionary comprehensions in Python too :) ```python from collections import deque def More
brute-iken 1
Hi, the if...else is redundant. More
One line-titaneric 1 1
Hi, `[2:]` is redundant as `bin()` returns a string in `0x...`. Regards, suic More
First-davidezal 1
This is so funny :) 1. "all the magic" (including `itertools.groupby`) on one-line. 2. wrapped by a typical newbie `if...else...` anti-pattern. ```python return ( subj.isupper() # bool or subj.endswith('!!!') # bool or any(...) # bool ) More