57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 13 minutes ago
Member for 11 years, 6 months, 7 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
You could have written `range(ord("a"), ord("z")+1)` for maintainability. :-D
More
You could have just slapped `functools.lru_cache(maxsize=5000)` on your `dec_to_rom` and call it `checkio`. :-P
More
Line 21 would probably be easier to parse if you'd filter a set to get a set: {(x+1, y), (x, y+1), ...}. And when you see this, it's even better to write do\_not\_hurt as a _set_ of possible indices, and just intersect your set of offseted positions with it.
Also, when you have a set of possible in
More
Nice handling of empty stack. :-) But the end is just
return not stack
More
Few nitpicks:
* romanNumeralMap really should be a dict. Yes, I know it won't be sorted, but you can sort it by value without problems, and it would probably help readability.
* input checking leaves a lot to be desired. What if n is "123a"? isinstance(n, int) (or using ABC) would be much better.
More
Nice usage of time module.
conv_dict could be much less repetitive if you looked up things like this:
m = int(mv) * conv_dict[mm.rstrip("s")]
(New TransformDict might help you in Py3.5, if it makes it there.;)
And of course, that code repeated twice should be factored out as a function, just
More
Inspired by an (algorithmically beautiful, Pythonically ugly:) [RRRQ's solution](http://www.checkio.org/mission/striped-words/publications/RRRQ/python-3/first/).
More
I've seen that many people look for my solution of this mission, and they only find the horrible code I've written about three years ago, when I first solved this mission. I think it's a shame. In the meantime, both I and Python have become much better, and this is the result. :-)
More
Nice and short. Few details:
* if cells was reversed, it would probably be faster. popping and inserting 0th item is O(n), while for last element it's amortized O(1).
* that backslash at line 9 end could be avoided by using de Morgan rule, not a and not b and not c ... written as not(a or b o
More
I like it too. :-) Of course, it can be refactored (to remove repetition) as
sum(((t-f).days+(f.weekday()+i)%7+1)//7for i in(0,1))
:-]
More
Nice recursion. :-)
sorted. Lose the brackets. You know the drill. ;-)
In fact, I think this would be a good place to teach you about enumerate.
for index in range(len(sequence)):
do something with index and sequence[index]
is pythonically written as
for index, elemen
More
A very nice idea. :-) However, the implementation of is_perfect_square could be more robust by using round instead of int.
More
It could be even easier. You should usually put normal cases first, exceptional ones later.
max(args) - min(args) if args else 0
Or, you can exceptionalize inwards:
max(args, default=0) - min(args, default=0)
:)
More
1. Revolver can be derived from collections.deque with maxlen=6, thus giving you loading logic for free.
2. Those triple-quoted strings are an abomination. Use textwrap.dedent, or just use "\n" like a normal person. :-)
3. A bug: chew_cigar doesn't reduce the number of cigars.
4. Those enemies co
More
This is a nice example of how chaining can help you write better code.
First, x == 1 and y == 1 can be written as x == y == 1.
Then you see you have it also in equivalence.
if x == y == 1 or x == y == 0:
Then you see you can factor out x == y.
if x == y in (0, 1):
Then you realize that
More