38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 12 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?
Ah, so I guess that's why the input can't just be any value but must be an iterable :-P
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
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
Shortened:
def follow(instructions):
globals().update(collections.Counter(instructions + 'barfly'))
return r - l, f - b
More
Another 2-liner :-P
```python
beat_previous=lambda D,p=-1,c=0:[[p:=c]
[c:=0]for d in D if(c:=c*10+int(d))>p]
```
More
Inspired me to do it **with** it, here's one version:
```
def compress(items):
from itertools import compress, tee, chain, starmap, pairwise
from operator import ne
a, b = tee(items)
return compress(a, chain([True], starmap(ne, pairwise(b))))
```
Another:
```
def compress(items):
More
Just a variation...
long_repeat=lambda l:max(map(len,__import__('re').split(r'((.)\2*)',l)))
More
[You're a bit late](https://py.checkio.org/mission/monkey-typing/publications/StefanPochmann/python-3/sum-map-__contains__/) :-P
More
Same as [my other solution](https://py.checkio.org/mission/cipher-dict-decryption/publications/StefanPochmann/python-3/directions-please/share/6d032a971ac33cf1f3f252187039f79f/), except this **can** handle texts like `'\tfoo'`. In that case, the hex string has odd length and `bytes.fromhex` complain
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
Collecting None, sweet. Or is that just to confuse+educate? :-)
`0<=ij>=0` would have been nice as well. Or `n>i>-1More
This seems quite buggy. Some test cases (with input, what I'd expect, and what you return):
```
'ud' None 0
'udd' None 1
'dud' None 0
'udud' None -1
'uddd' None 2
'dudd' None 2
'ddud' None 0
'ududd' None 0
'uddud' None -1
'dudud' None -2
'duddd' None 4
'ddudd' None 4
'dddud' None 0
'ududud' None -1
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
The power is not enough to handle `create_intervals({0, 1234567890})`, crashes with a `MemoryError`. But still a nice idea. Second line can be simpler/shorter:
return [(x + 1, y - 1) for x, y in zip(ex, ex[1:]) if y - x > 1]
More
Code reuse is always good. Plus, this is how they'd do it in the movies.
More