57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 12 hours ago
Member for 11 years, 6 months, 6 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.
Aargh. Don't write C# in Python. And _please_ don't use pseudoHungarian notation. It completely misses the point of Python.
Also, learn Python idioms. Many of your lines can be written in a clearer, sometimes even point-free way. In some cases you don't even need to learn new idioms, just use them
More
Why didn't you just put s=0 in line 1, then you don't need line 2 at all?
Also, len() is unnecessary. Sequences are boolable.
More
Argh, float("%.2f" % x)... you really should use the function "round". ;-)
More
I know you're proud of this solution (I read your blog;), but your operators are a bit convoluted, your if is unneeded, and your iteration is half-baked (literally;). How about this:
def checkio(number):
numerals = { ... }
roman = ''
for value, phrase in sorted(numerals.
More
Not bad. Handling singular cases is cool. :-)
You might want to use some of Python's batteries, though. For example,
for a, b, c in itertools.permutations(eval(data)):
with contextlib.suppress(ZeroDivisionError):
... lines 7 ~ 12
... lines 17 & 18
seems much ni
More
"Improvement" depends on the criteria. I surely think that just trying the bases until one works is more intuitive than calculating the maximal digit value --- but of course, the second one is faster.
More
... but def loop. :-)
Nice. Though you didn't really need another function... checkio could be called recursively. :^)
More
You don't need first condition in line 6. ;-) (Also in line 9 if you write it with slices.)
More
I always say this, so I'll say it here too, although I'm sure you know it. :-)
sum(1 for blah if cond)
is just
sum(cond for blah)
Iverson FTW. ;-)
Also, you don't need parentheses in line 11.
BTW, I'd swear there was a more obvious way to add something to a Counter than wha
More
It's fascinating that the same solution, somebody puts under puzzle, somebody under clear. :-P
More
That's how I planned to call my solution, bit there might be children around. 😛
More
Nice usage of conditional expression. However, it would be much nicer if you explicitly checked n in range(len(array)), or at least 0<=n< len(array). I know of preconditions, but it's not much harder to write those additional conditions explicitly.
More
:-) If you're going to use `len() and`, you can use it in at least two other missions. Try to find them. ;-]
More