38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 24 minutes ago
Member for 9 years, 1 month, 4 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?
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
Just a variation...
long_repeat=lambda l:max(map(len,__import__('re').split(r'((.)\2*)',l)))
More
I wasn't in the mood to do checks **during** the pattern-to-number conversion, so instead I just did the operations and afterwards asked myself for the pattern and compared.
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
How about...
def merged(intervals):
if intervals:
it = iter(intervals)
a, b = next(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
Uh... That's not a bunch of one-liners, that's one bunch-liner :-)
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
I also like `n in (round(n**e**-1)**e for ...)`, but that of course has the huge disadvantage of not allowing a title like yours.
More
If I remember correctly, I got that complex number trick from @veky years ago.
More
Collecting None, sweet. Or is that just to confuse+educate? :-)
`0<=ij>=0` would have been nice as well. Or `n>i>-1More
One char shorter:
```
checkio=lambda*a:len(a)and max(a)-min(a)
checkio=lambda*a:max(a:=a or[0])-min(a)
```
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
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
Thanks to [james.verran](http://www.checkio.org/mission/end-of-other/publications/james.verran/python-27/endswithtuple/) and [MadCow234](http://www.checkio.org/mission/end-of-other/publications/MadCow234/python-27/the-end-of-other/) for pointing what `endswith` can do.
More