15
vikulin
2 17 25
1136/ 1195
Alexander Vikulin
Last seen 1 year ago
Member for 9 years, 8 months, 2 days
Difficulty Normal
Best reviews / Newest reviews
Straightforward-veky 1 1
is this efficient way of doing that? wouldn't starmap first run str.endswith for ALL permutations before any checks for Trues? More
dict FTW-veky 1 1
this is humiliating! :) i even employed recursion to solve this one, and yours looks so concise and ummmm... simple, when you get a hold of it... although, it's surely not the most "clear" one. ;-) More
math.log-vikulin 1
still this is about 10% slower than a while solution: def friendly_number(number, base=1000, decimals=0, suffix='', powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']): d, n, p, p_len = decimals, float(number), 0, len(powers) - 1 while abs(n) >= base and More
First-gyahun_dash 1
**or gifts == number** part is useless, because this is definitely not the best gift anyway and this bag is lost already. after **number > gifts // 3** updating **maximum** is a waste of time since any gift better than maximum will return True and terminate bag processing. calculating **gifts // 3 More
First-mihaillebedevdev
While digging into how this speedy solution works I discovered that it fails for the following case: assert break_rings(({3,4},{4,5},{5,6},{6,7},{7,4},{3,8},{8,9},{9,10},{10,11}, {11,8},{3,12},{12,13},{13,14},{14,15},{15,12},{3,16}, {16,17},{17,1} More
WET-veky 1
this time i learned that i can slice beyond upper bounds and walk away with it. man your code is so enlightening! More
Any N-dim cube, any cube edge side-vikulin
This was inspired by [veky](http://www.checkio.org/user/veky/)'s elegant [solution](http://www.checkio.org/mission/the-square-chest/publications/veky/python-3/two-counters/), where he challenged the readers to improve his code to work for cubes of _any dimension_ and _any cube edge length_. Test wi More
Cubes in a multidimensional space-vikulin
This is a more optimal version of [this solution](http://www.checkio.org/mission/the-square-chest/publications/vikulin/python-3/any-n-dim-cube-any-cube-edge-side/) Which was a solution inspired by an elegant [veky](http://www.checkio.org/user/veky/)'s [solution](http://www.checkio.org/mission/the-s More
while-vikulin
this is about 10% faster than using **math.log** from math import log def friendly_number(number, base=1000, decimals=0, suffix='', powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']): p = min(int(log(abs(number), base)) if number else 0, len(powers) - 1) More
Default value trick-vikulin
This solution is notable for 3 things: 1. It uses an interesting feature of function [Default Argument Values](https://docs.python.org/3.3/tutorial/controlflow.html?highlight=define%20functions#default-argument-values) to persist values between function calls. This saves us from defining a global v More
Speedy DP-gyahun_dash
The best - fast, concise and readable. More
recursive devision-vikulin
**if n//10 else 1** will reduce recursive calls by one, but will calculate **n//10** twice as many times... or will it be optimized by jit compiler/interpreter? More
Dynamic Programming-z_kro
This is more than 6 times slower that this [solution](http://www.checkio.org/mission/loading-cargo/publications/vikulin/python-3/dynamic-using-sets-fast-short-and-readable/) More
First-vikulin
This is about 50% faster than checkio=lambda d:[x for x in d if d.count(x)>1] I guess d.count(x) is not cached for repeated calls with the same x. More
Fast-vikulin
This is faster than each row updating histogram and scanning it for the largest rectangle, but it uses more memory. More
Short, Clear and Simple-vikulin
Pay attention that because of the way Python initializes and treats default function arguments when mutable objects are used as default values, all changes to the **counter** will be retained through subsequent function calls. More
Fast and simple-vikulin
This version runs much faster than my first simple solution shown below, because it scans the whole field only once during the first step. After that it only scans cells that where good on a previous step. from math import hypot from collections import Counter def checkio(prev, counter More
Fast and simple-vikulin
Note that modifications to **counter** object will be retained through the function calls, because of the way Python works with default parameters values. More
O(n) :-P-veky 1
isn't this solution faster? def checkio(data): from collections import Counter c = Counter(data) return [x for x in data if c[x] > 1] More
First-melpon
brilliant! the best solution i've seen. More
1
2