40
suic
16 39 57
9964/ 10664
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Best reviews / Newest reviews
Roman numerals-chido
As functions are [first-class citizens](http://en.wikipedia.org/wiki/First-class_citizen) in Python, you can write line 19 like this: "".join(f(data) for f in (getThousands, getHundreds, getTens, getUnits)) More
First-Babyhome.beerz
Man, this is scary. So much redundancy: there's the same pattern 13(!) times. Other things: 1. All the _nix_, _ni_, etc. are redundant and _niv_, _nix_, _nxl_ and _ncd_ are not used at all. E. g.: nv = num / 5; ans += 'V' * nv # is the same as ans += 'V' * (num / 5) 2. Semico More
First-Syaopin
I like your approach. In fact you can replace lines 44-52 with two lines of code :) dig = str(dig).zfill(4) return "".join(c[dig[i]] for i, c in enumerate((thou, hund, tens, ones))) More
short + easy_to_understand (9th_solved)-Ugen
Check the [_divmod_](https://docs.python.org/3/library/functions.html#divmod) built-in function. data, rest = divmod(data, 10) # instead of: rest, data = data % 10, data // 10 More
First-RubenDjon 1
Hi, I have to comments. First you don't have to import string you can use string methods instead (try to look at help(str) or [here](https://docs.python.org/3/library/stdtypes.html?highlight=str#string-methods). There's quite a lot of redundancy in this code. Lines 5-7 contain the same pattern. It More
First-AQiccl135 1
It's subjective but in this case using list comprehension would be nicer and also shorter :) More
First - Roman numerals-AQiccl135 1
Hi I like your solution except from two things: 1. For thousands you can use the same logic as for ones, hundreds and tens as 'M' * 0 == '' # then: romanNumeral = THOUSANDS[(data // 1000) % 10] 2. Lines 8-10 (or even 7-10 if you apply my point no 1) contain the same patt More
Verbose-capehart
You can negate the first condition here: if y == row and x == col: pass else: if grid[y][x]: count += 1 and reduce it to this: if not(y == row and x == col) and grid[y][x]: count += 1 or even: count More
Short, but not speedy.-tommycarstensen
Hi, line 5, 6 are almost the same. It's a good candidate for `lambda` or list comprehension. More
First-carloszampiere
Hi, forget about semicolons, please :) More
First-carloszampiere
Hi, 1. `lados` is redundant. `args` is a tuple => is iterable, so _list()_ is redundant. 2. you should decompose `args` like this: a, b, c = args 3. You don't need _math.sqrt()_, there is the [_pow()_](https://docs.python.org/3.4/library/functions.html#pow) built-in function, and the `**` ope More
First-tommycarstensen
Hi, 1. Line 6: [] are redundant. 2. Look at _filter()_ cnd = collections.Counter(filter(str.isalpha, text.lower())) 3. Line 7 that `for x sorted(): break` is so ugly. What's wrong with?: return sorted([t[0] for t in most_common if t[1] == cnt_max], key=operator.itemgetter(0))[0] More
First-vak123
fib += [age] is the same as fib.append(age) More
First-vak123
A _for_ loop would be a better solution for lines 5-10 e. g.: for rep in (('IIII', 'IV'), ('VIV', 'IX')...): large = large.replace(*rep) __*__ before _rep_ unpacks the tuple. More
Even the last-EfGnevsheva
Hi, 1. look at [_extended slices_](https://docs.python.org/3.5/whatsnew/2.3.html?highlight=extended%20slices#extended-slices). 2. `if not array:` is enough. More
Andrew G-agalazka
0 < len(array) <= 10 and 0 <= n and all(0 <= x <= 100 for x in array) are preconditions so you can omit line 3. More
OMG-agalazka
Nice, but you can make it even shorter. More
First-agalazka
This is not very pythonic: text.lower().find(i) != -1 use _in_ instead: i in text.lower() More
Three words-EfGnevsheva
Hi, `return` is a statement not a function. Parentheses are redundant. More
First-Elrengil
You can write: if all(i.isalpha() for i in words[w:w+3]): instead of: if words[w].isalpha() and words[w+1].isalpha() and words[w+2].isalpha(): More