38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 3 hours ago
Member for 9 years, 1 month, 22 days
Difficulty Normal
Recent solutions I'm happy with (just starting/trying this):
[Words Order](https://py.checkio.org/mission/words-order/publications/StefanPochmann/python-3/short-dict-subsequence/share/5bbb2df54ec5a810d36d7f70ae7e92da/)
Dang it no markdown here?
You [reinventor](https://github.com/python/cpython/blob/de7a2f04d6b9427d568fcb43b6f512f9b4c4bd84/Objects/listobject.c#L2306-L2314) :-)
More
If you're willing to handle float imprecision like that, you might as well use complex numbers. Then you could generate the neighbors of a point `z` simply as `{z + 1j**(i*2/3) for i in range(6)}`, and `almost_equal` of two points could simply be `abs(z1-z2) < 1e-5`. I used complex numbers for the n
More
That's pretty bad. Try `postfix_evaluate([2, 3, "/", 10, "*"])`. Causes an infinite loop and memory explosion, because you mistake the float for an operator. If you use `type(v) == str`, that problem goes away, but you incorrectly return 7 instead of 0, both because you round instead of flooring and
More
Hmm... how did you get that here? The function name is wrong, the return type is wrong, and I just tried it and it does get rejected.
Edit: Ah, [I see](https://py.checkio.org/forum/post/12041/new-mission-the-highest-building/) that was apparently the original format. Does CheckiO not rejudge soluti
More
Explanation: For each center cell c, go through all cells and count the bacteria at each Manhattan distance. Then use that to find the smallest non-full "ring" around it and if that ring is empty, we found the radius of the colony.
It's not efficient, but it is simple (and it doesn't have to be eff
More
Just a variation...
long_repeat=lambda l:max(map(len,__import__('re').split(r'((.)\2*)',l)))
More
Somewhat golfed:
```python
from sympy.combinatorics.permutations import Permutation
fifteen_puzzle=lambda g:Permutation(L:=sum(g,[0])).parity()==sum(divmod(L.index(16)-1,4))%2
```
More
Combining your backwards idea with my "speedy" idea of using one lookup per move:
```python
from functools import reduce
u, f, r, l, b, d = ({'side': i} for i in range(1, 7))
def set(state, *NSWE):
state |= zip('NSWE', NSWE)
set(u, f, b, r, l)
set(f, d, u, f, f)
set(r, r, r, d, u)
set(l, l, l,
More
Hmm, now what to do with this... I gave the original +5 for its neat insight/algorithm. I do like this version better, but it didn't give me that same Aha! moment again...
More
Note that `*` binds stronger than `in`, so the `*` is not your typical simple `and` replacement between two bools here.
This is even "fast"! As soon as one letter is missing, the others are only searched in the empty string. Too bad I still `upper` the string before imploding it.
More
Could've been clearer without the shift. Put "zero" at index zero, "positive" at index +1, and "negative" at index -1.
```python
def determine_sign(num: int) -> str:
sign = lambda i: (i > 0) - (i < 0)
return ["zero", "positive", "negative"][sign(num)]
```
More
Unfortunately I looked at veky's solution before thinking much, so I can't claim this as my own. I made the regex shorter, though.
More
I'd say removing less than nothing shouldn't remove *everything*, like this does for `remove_min_max({1, 2, 3}, -1)`.
More
Inspired by yours:
def remove_min_max(data: set, total: int) -> set:
for extremum in [min, max] * total:
data.discard(extremum(data, default=None))
return data
More
If I remember correctly, I got that complex number trick from @veky years ago.
More
As a speedcuber, I'm loving this. It's like [these six edges](http://www.randelshofer.ch/rubik/patterns/U040.02.html).
More