16
kvas
1 11 26
1110/ 1445
Vasily Kuznetsov
Last seen 5 years ago
Member for 11 years, 6 months, 11 days
Difficulty Normal
Best reviews / Newest reviews
Second-Bibiche 2 1
This looks right. Congratulations! If you want to speed it up, you could probably get rid of eval and use sets instead of lists in some places. It also evaluates some subexpressions multiple times, so those could be cached. More
First-blackfaced 1
I'd rewrite things like [graphs[c].discard(root) for c in nodes] to: for c in nodes: graphs[c].discard(root) for more pythonic and less confusing look, but otherwise it looks very nice! More
First-scturtle
return l[0]==100.0 I'd be careful with comparing floats just like this. But if it works... :) More
Recursive Generators-AndriusMk
Nice! Simple and elegant. BTW, it's also possible to make it work with floats instead of fractions. In my experiments that was about 10 times faster. More
Short version, inspired by other solutions-kvas 1
I also tried caching the result of comb\_values, but in python2.7 is only makes things slower. In python3.3 with functools.lru\_cache it might be worth it, but I don't have python3.3 on my computer to check. More
First-blackfaced 1
You could also import the operations (+-/*) from operator module (there's also truediv there which behaves like python3 division). And if performance is important, inlining it like this: results[(j, j + i)].add(m + n) results[(j, j + i)].add(m - n) results[(j, j + i)].add(m * n) More
LuckyTickets-Fjodr
Cool idea! You could probably also factor out the common part of add, mul, sub and div. More
Comprehend-veky 1
Pretty awesome! BTW, the ratio of lucky to unlucky tickets is around 1/10. More
Boring...-kvas
This is a very boring solution, I hope somebody comes up with something more clever ;) More
Pseudo-Morse-PositronicLlama
return "{0:0{1}b}".format(number, bits).translate(TO_MORSE) Nice! I didn't know you can do this. More
Boring...-kvas
def extract_cells(r, c, dr, dc, count): Ignore the extract_cells function, I forgot to delete it. More