Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
That depends though, in most static languages the return type would still be consistent - just optional/nullable. I believe this is actually the official idiomatic way to do it in Python as well, though I'm not digging through all the PEPs to find it.
This is a language specific thing in general though, most functional languages will want to use optional typing (or even a partial function) since that's generally how their stdlibs are designed.
I don't know. I like the style where, if the expected return value is a positive integer, then using a negative integer to indicate invalid input makes the return type consistent.
Your kata, up to you. Though 4k may very well not be able to stop naive solutions in faster languages.
If I was changing something I would rather it was making return for invalid input
None/undefined/null/nil/etc
rather than-1
.Thanks!
Do you want to raise the input limit above 4000?
Oh wait I lied, I also added 1 extra random test so there is 100, 99 random tests was bothering us.
Fixed with boolean check of all time, this is why I don't like these fancy preloaded validators.
Also, I wouldn't be surprised if your method was actually faster than mine if you made the
{'9'}
a constant somewhere since it's all c functions in the stdlib at that point vs pure python.it thinks
0
is all9
'ssomething that's nearly as fast:
return set(str(x)) == {'9'}
.. or specialcase 0 I guess
Reading the description should make the condition for m being undefined very obvious.
The limit on
x
probably shouldn't be dictated by Python int parsing limitations just because your tests rely on it. I'm also not 100% sure your testing function is airtight outside of your very limited input range.Python fork removing reliance on string casting, halving test runtime. If you account for the ~500ms constant factor of interpreter startup then test runtime is sped up by around 5x (~150ms vs ~800ms).
Case not actually added to most languages as far as I can see.
Fixed in Scala
Fixed in CoffeeScript
This issue not actually resolved, test only added to python.
Also, expected value of that test is 2, before anyone tries to add it in some fucked up way with a refsol again.
Bruh who approved it with that in there, fixed.
Loading more items...