38
Awesome Team
Stefan Pochmann
http://www.stefan-pochmann.info/
Last seen 4 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?
`a` and `b` keep track of the best sums up until the previous two steps. [One-liner version](http://www.checkio.org/mission/stair-steps/publications/StefanPochmann/python-3/short-simple-efficient/).
More
`chi` is nice. But what does the name mean here?
I don't see a reason why this wouldn't work for other sizes (as long as it's small enough to be fast enough).
More
"Speedy" as in I get it after just one guess. I challenge you to find two expressions which are *not* equivalent but which my x,y pair fails to distinguish.
More
125 is the file size in bytes. It's 127 with double spaces instead of tabs. Here's another 127:
def total_cost(C):
M={}
for c in C:M[c[:10]]=M.get(c[:10],0)-(-int(c[20:])/60)
return sum(m+max(0,m-100)for m in M.values())
More
Credit to @jimako1989 for his `all([x+y>z,y+z>x,z+x>y])` which I just shortened to my `a+b>c>b-a>-c`.
More
Alternatively (same length):
checkio=C=lambda c,n,s='',i=0:s*(i==n*2)or C(c,n,s+','*(i>i%min(c,n)<1)+`i%n`,i+1)
More
Same as [this](http://www.checkio.org/mission/stair-steps/publications/StefanPochmann/python-3/short-simple-efficient-clear/).
More
Just reusing [my solution to the original mission](https://py.checkio.org/mission/roman-numerals/publications/StefanPochmann/python-3/short-and-clear/).
I could write it as
reverse_roman = list(map(checkio, range(4000))).index
but then I'd have to write it *below* the `checkio` function :-(
More
Apparently the judge doesn't even care whether I return the intervals as tuples or lists...
More
Apparently the judge doesn't care whether I actually return a `bool`. Here's a 53 that does:
checkio=lambda p:p[9:7+len({ord(x)>>5for x in p})]>''
And here's a 54 based just on przemyslaw.daniel's:
checkio=lambda p:len(p)-7>2>5for x in p})
@przemyslaw.daniel's 62 is [here](h
More
A variation, one character shorter and perhaps a little nicer/faster:
def merge_intervals(intervals):
r, E = [], float('-inf')
for s, e in intervals:
if s > E + 1:
r += [s, e],
E = r[-1][1] = max(E, e)
return r
More
This should be O(n) because the `sorted` shouldn't be necessary. It only is because the judge currently wants the output intervals in a certain order (even though the problem specification doesn't require that). Already reported this judge bug...
More
The actual creation of the intervals only takes O(n) time, but the required sorting makes it only O(n log n). Makes me sad :-(
Could use `range(start, start+len(data))` instead of `count(start)` if I wanted to avoid the import, but `count(start)` is much nicer and faster.
A golfed version (would b
More
Um... how do you think `start - data[index] == 1` or `start -data[index] > 1` can ever be true?
More
What's the point of explicitly creating those two temporary extra lists in the first line? `sorted` is perfectly happy with getting a `set` and it already returns a `list`.
More
Reversing `data` seems like an attempt to make it fast, but it's still only O(n^2) because of the repetition of the expensive line 13.
A little experimental confirmation, doubling the input size roughly quadruples the time (I removed your `print` line for this):
```
>>> from timeit import timeit
>>
More