38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 7 hours ago
Member for 9 years, 1 month, 5 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?
Shortening it by removing code duplication (but I'm afraid it makes it a little less clear):
def create_intervals(data):
return list(zip(*(sorted(x for x in data if x+d not in data)
for d in (-1, 1))))
And golfed:
create_intervals=lambda X:list(zip(*(sort
More
Took me forever to find those index expressions. My progression was:
checkio=lambda n:'Fizz Buzz'[(n%3>0)*5:4+5*(n%5<1)]or`n`
checkio=lambda n:'Fizz Buzz'[n%-3&-4:4+5*(n%5<1)]or`n`
checkio=lambda n:'Fizz Buzz'[n%-3&-4:9-n%5-n*4%5]or`n`
checkio=lambda n:'Fizz Buzz'[n%-3&-4:12-(n%-5&8
More
Zip the interval starts with the interval ends. Similar to [my previous solution](https://py.checkio.org/mission/create-intervals/publications/StefanPochmann/python-3/simple-oneliner/), so I could've seen this myself, but really just a corrected and improved version of [Lemmi's solution](https://py.
More
Alternatively, a little more efficient and maybe clearer:
def merge_intervals(intervals):
result = []
for interval in intervals:
if not result or interval[0] > result[-1][1] + 1:
result.append(interval)
else:
result[-1] = r
More
Dictionary version :-)
```python
def calkin_wilf(n: int) -> tuple[int, int]:
result = {'1': 0, '0': 1}
for bit in f"{n:b}":
result[bit] = sum(result.values())
return tuple(result.values())
```
More
For example `correct_sentence('I')` crashes ("I." is a perfectly fine sentence, and since a point of the mission is to correct a missing dot, `'I'` is a perfectly reasonable input).
Btw, how about `tail.strip(".") + "."`?
More
Still one character longer than [mine](https://py.checkio.org/mission/house-password/publications/StefanPochmann/python-3/shortest/?ordering=most_voted&filtering=all) :-P
But it's trivial to make yours shorter. Why don't you use a set comprehension?
More
Disproof: From goal state, just swap blue with yellow. You can't solve it because you never turn rings 2 and 3.
More
Ah, I should've suspected you've done this already.
No need for `b` if you use `find` instead of `index`.
More
I finally [beat you](http://www.checkio.org/mission/fizz-buzz/publications/StefanPochmann/python-27/shortest-52-kill-me-now/)... omg that was hard work. Thanks for the motivation :-)
More
Just shortened the third line a bit (required changing the characters):
checkio=lambda i,r=range:int(bytes(48+min(r(10),
key=lambda n:bin(ord('歫⒚玧碧䧭㣏毎ኧ篯㧮'[n])
^sum(i[o//3][d+o%3]<More
Shortened:
def follow(instructions):
globals().update(collections.Counter(instructions + 'barfly'))
return r - l, f - b
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
Code reuse is always good. Plus, this is how they'd do it in the movies.
More
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
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
I did almost the same, just decided to go with `filter(None, sorted(L))` so I don't need to type `iter()` :-)
More