38
Awesome Team
Jürgen Strobel
Last seen 3 hours ago
Member for 5 years, 1 month, 24 days
Difficulty Normal
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
Nice stack/slist. Any special reason you chose (tail, head) in the opposite order than customary?
More
Using a bit more from numpy you could vectorize everything in this mission.
E.g. `numpy.subtract.outer` on points basically replaces your 2 outermost loops, it creates a matrix using a full outer join with pairwise subtraction for all points.
More
I am wondering if binary search is strictly optimal, or an approximate solution (polynomial) could be used to guide the search ;-)
More
Python's rather new built-in `int.bit_length` makes `msb` superfluous. Curiously everyone copied it or imported `math.log2` instead.
More
Why the `deque`? You are appending and popping on the right side only, which is efficient for a simpler `list` already.
More
A fine algorithm, but a `list` would make a far better stack than a `str`.
More
In retrospect, the pattern could be simplified to `rf'({_l}{_u})|({_u}{_u}{_l})'`.
More
You could replace the first inline-if too:
return num and (num % 9 or 9)
More
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
`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
Cool. There's `graphlib.TopologicalSorter` in the stdlib now too, but it needs some tweaking to get the [alphabetical order correct](https://py.checkio.org/mission/determine-the-order/publications/juestr/python-3/graphlibtopologicalsorter/).
More
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
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
That's cool, but I guess it relies on unique node values. Which the examples and tests imply, and maybe graph theory also, but my developer self would have needed it spelled out. :/
More
Strictly speaking the way you `split()` is incorrect. Words might be separated by punctuation only, although no tests do this.
More
Strictly speaking since `items` is an `Iterable` we shouldn't use `[]` on it. (The tests are bad.)
More
Version with a recursive _generator_ :-)
https://py.checkio.org/mission/88th-puzzle/publications/juestr/python-3/first/
More