57
veky
22 48 64 Leader of the month
44584/ 53887
Last seen 22 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.

Best reviews / Newest reviews
First-oglop
Of course, you can just return [x for x in ...] But in this CiO context, giving a return value a semantic name is even justified. Though of course, not in the real code - then the _function name_ should be used for that purpose. More
First-s_o_va
Too many indices! :-o But this is minor. Real problem is using 10 and 100 as magic numbers. Besides being maintainability hell (network expands, and in some random moment in the future, your code gives wrong results silently), documentation is lacking. Comments do help at the moment of assignm More
First-MrPablozOne
Nice shortcircuiting when len < 10. Lines range(9, 18, 3) ;-): comparisons can be chained. if 'a' <= i <= 'z': Even better: `if i.isupper():` (also `islower` and `isdigit` are available). Comments and those print "debug" statements should be deleted before publishing. It's nice that you _co More
First-MrPablozOne
Horribly complicated. Did you see the hint? .count is your friend. del data[data.index(i)] ~~~> data.remove(i) Partial unrolling of loops (line 6 == line 17) is a very common source of very hard to find bugs. Don't do that. Instead of lines 6 and 17 just write it in line 10. Here More
First-MrPablozOne
Line 6: chaining is cool. if number % 3 == number % 5 == 0: Lines 8 and 10: `not` is cool too when checking divisibility. if not number % 3: And `str("Fizz")` is like `list([3, 5])` or `float(3.14)`: completely redundant. ;-] More
First-MrPablozOne
You don't have to write len(array) inside array[...]. Just ... * array[-1] About součet: it's called `sum` in English. def evens(array): for index, element in enumerate(array): if not index % 2: # remember this from FizzBuzz? ;-) yield element souč More
First-MrPablozOne
As I said, line 2 is just if not args: Or you can hackingly use the fact that 0 is the same: return len(args) and (...big - ...small) (BTW naming can also be chained: `big = small = args[0]`.) But for that to function, you have to calculate big and small in expressions. However, that's More
First-martin.beseda.3
a * -1 is more usually written as -a. :-) More
Second-aminami1127 1
Nice. However: len([y for y in blah if cond]) ~~~> any(cond for y in blah) is much clearer and it shortcircuits, while len-version doesn't. But even better IMO would be if connected were a _function_ taking an index and returning a set. (It could be local to `capture`, so it could access More
Counter-gyahun_dash 1
Handling constants is not so hard. But this is ok. Are you sure you need list() in line 27? starmap would probably slurp from filter just as easily. More
Req-geruz
Line 18 is ugly. Three suggestions: * (simplest) Use dictcomp: {a:[] for a in range(1,9)} * (correct but long) Use graph.setdefault(node1, []).append(node2) * (most correct) Use collections.defaultdict(list) (BTW maybe set would be nicer) * (hacky) Use a list: indices are small positive ints anyway More
First-reviewboy
You should use divmod builtin. Much clearer than juggling with / and * and -. Also, wouldn't it be nicer if you indexed into START = [None] + FIRST_TEN + SECOND_TEN OTHER_TENS = [None]*2 + OTHER_TENS ? You could remove all these indexing offsets. More
First-reviewboy
Computation of x (line 11) really should be outside of if, right? Also, float(x)+float(y) is float(x+y). Or just divide by 2.0. Or write in real Python. ;-) More
First-reviewboy
You could have deleted all these comments. :-) More
First-reviewboy
Pythonic way is to bool it as a test for emptyness: if array: return array[-1]... else: return 0 More
First-reviewboy
Nice. You could have avoided duplicated int(digit) with for digit in map(int, str(number)): More
First-reviewboy
Again, "if not args" (or reverse logic, if args) is much nicer than "if len(args) == 0". Even better would probably be to use if...else expression. More
First-reviewboy
You could have used .count on bin(number), instead of writing it from scratch. Also, don't give irrelevant names ("x" doesn't really mean anything) to things used only once. "for c in bin(number)" is better, since reader doesn't have to jump around the code searching "what the ... is x?". More
First-reviewboy
Nice, but filter with lambda is probably nicer expressed as genexp: ...sorted(x for x in first.split(",") if x in second.split(",")) Better expresses symmetry. Of course, better still would be x from first.split(",") if x in second.split(",") if Guido ever allows that. :-D More
First-reviewboy
sorted gives you a list anyway and consumes any iterable, no need for list(words_set). any accepts genexps, drop the [] to be much faster and memory efficient (you don't calculate the whole list, only the part until first true, and you only keep one cell in memory). Use str.endswith method instead More