38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 5 hours ago
Member for 9 years, 1 month, 3 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?
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
I posted a [fixed(?) version](https://py.checkio.org/mission/frogs-collision/publications/StefanPochmann/python-3/fixed/share/4ab004d485da914baed376b1ffa0a6a1/), as this returns `0`, `0` and `-1` instead of `1`, `1` and `None`:
```
frog1 = 0, 0, 0, 0
frog2 = 0, 0, 0, 0
print(frogs_collision(frog1,
More
What's the explanation for counting odd divisors? Without that, this isn't "clear" at all.
More
Same as my first solution, but after seeing @veky's title saying complex.
More
Benchmark results (executed on CheckiO):
```
226 ns max
82 ns max_of_three
221 ns max
81 ns max_of_three
220 ns max
82 ns max_of_three
```
Benchmark code:
```python
from time import perf_counter as time
from itertools import repeat
def max_of_three(a, b, c):
return (a if a > c
More
I can't reproduce your findings supporting that this is "The Fastest". Please share your benchmark results and your benchmark code. Here are mine:
```
226 ns max
82 ns max_of_three
221 ns max
81 ns max_of_three
220 ns max
82 ns max_of_three
```
```python
from time import perf_counte
More
We should have a "Tardy" category for highly inefficient solutions like this :-P
More
Two ways, can't decide which one I like better.
Half of my old [LeetCode](https://leetcode.com/problems/isomorphic-strings/discuss/57892/1-liner-in-Python) solution for Isomorphic Strings.
More
Memory of what? Of times when people didn't complain about PEP 8 violations and plagiarism?
More
All just variations of the first solution, i.e., compare the first and last value of the current group and the new item.
I was lazy typing, so `a` means first group value and `y`/`z` means last two group values (if `z` were included in the group).
More
[Previously](https://py.checkio.org/mission/cipher-dict-decryption/publications/StefanPochmann/python-3/directions-please/share/6d032a971ac33cf1f3f252187039f79f/) I sorted. I believe it failed the tests without. If works now. Not sure what happened. I just saw Phil15's solution, which didn't sort, s
More
Wtf... And you call **me** a "pairwise∘groupby freak"??? Let's see whether I can decipher this...
More
Another benchmark where I try to expose the reallocations by both ins the same list object over and over again but instead make copies and use each only once. Despite all my efforts the results aren't super reliable, though, I might have to try again when I have access to a more stable machine.
```
More
Like my [original](https://py.checkio.org/mission/remove-all-after/publications/StefanPochmann/python-3/elephant-in-cairo-fast-all-rounder-with-benchmarks/share/2f2991cd6fa3280f7cf2bf62f0f6146b/) but simpler and might be faster. Here I temporarily *append* the border value instead of writing it into
More
Previous solutions mainly fall into three camps, each with its own downside. This solution avoids all those downsides.
- The [LBYL](https://docs.python.org/3/glossary.html#term-LBYL) solutions check `border in items` before calling `items.index(border)`. That double search becomes slow for long inpu
More
I actually think this is better than returning the original `items`. Consistently returns a new list instead of sometimes the original list, which could be dangerous.
More