38
juestr
17 44 52 Leader of the month
8720/ 9195
Awesome Team Jürgen Strobel
Last seen 22 hours ago
Member for 5 years, 1 month, 11 days
Difficulty Normal
Best reviews / Newest reviews
Third-gyahun_dash
That's a nice showcase of itertools (although I prefer importing the functions directly). I especially like how `avoidable` works. It's not very efficient though, `filter(satisfied, ...)` checks whole boards created by `product(*places)`. A lot of the search space could be pruned if placing queens More
5th-gyahun_dash
Yeah that's the right way to do it. I realized too late that *everything* is to be lowercased except the escapes, and that there is no reason to parse and handle the different parts of the URL separately. Of course, if the path would countain `:80` followed by a non word character this would break, More
Decimal FTW-veky 1
`decimal` can be used to do quantization, rounding and formatting of the result too. Funnily I didn't use it to find the right power as it can be done with integer math easily. More
juestr's reordered-veky 1
The search is much better structured now, but I'd still prefer doing it in integer arithmetic. if number // base ** i ... or even if number >= base ** i or not i: Yes I may need to repeat the last calculation in Decimal and can't show off a walrus, but given int operations are **much** More
regex-juestr
In retrospect, the pattern could be simplified to `rf'({_l}{_u})|({_u}{_u}{_l})'`. More
Optimal-veky 1
I am wondering if binary search is strictly optimal, or an approximate solution (polynomial) could be used to guide the search ;-) More
incremental inner product-juestr
This theoretically fast algorithm avoids a lot of repeated additions and multiplications by intertwining creating permutations and their inner products with `coeffs`. But in practice eschewing itertools.permutations or numpy does not pay off well, compare to [this](https://py.checkio.org/mission/cr More
First-jaunkunal029
Nice use of setdefault(), but there's a collections.Counter class would make this even more elegant. Also there's a way to avoid the sorting step, max (and min) can take a key= parameter and compare by 2 properties in a tuple at once, one being the count, the other the character itself, and one mul More
O(N)-PositronicLlama
It's also O(n) in space though, and you'd just need to keep the last 2 elements of `values` while iterating, making it O(1) in space. More
First-SmYul
OK let me be blunt: The len()==1 case shouldn't be necessary even for your code, as the next case would handle it just fine. Also you could just pick the middle 1 or 2 list elements by indexing [len(data)//2)] instead of removing everything else. I don't see how i is used, it's completely superfluou More
First-vlad.bezden
In Battle if an army is empty this will end with an UnboundLocalError since soldier_1_alive is never assigned to. No precondition to assure armies have units. More
First-Dr__ON 1
Index-based iteration in Battle.fight is non-pythonic (some might even say clumsy). Better options are explicit iterators + next() or popping the dead units off the armies. Btw catching the IndexError doesn't save you if army u1 is empty, since u1.members[-1] will throw another one. More
﴾ ̲◦̲ / ̅•̅ ﴿ ̮ ‿( ́ ̵ _-`)‿ ̮-vmiimu 1
i and enumerate appears to be unused? More
triangle-Rudeboyz_Squad 1
Short and readable, although I prefer a bit more whitespace. More
First-Mezze99
Does the job. However this does many more count()s than necessary. More
First-vlad.bezden
I don't see how the key lambda can work? In the first example both 6 and 2 get the same frequency hence the output should be in order of input: [4, 4, 4, 4, 6, 2, 2, 6]. That was my first attempt too but it got rejected. More
First-vitalik_force
You could define j before inline, and use j instead of jj in inline. More
long_repeat-dannedved
Works, but allocates more memory (counters) than strictly necessary. More
First-igor.v.dudenko
Works, but rather brute force. Can be done in a single loop by adjusting a sliding window's sum up and down. More
First-kkacc
Works, but rather brute force. Can be done in a single loop by adjusting a sliding window’s sum up and down. More
1 2 3
4
5 6