Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Default User Avatar

    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.

  • Custom User Avatar

    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.

  • Default User Avatar

    Thanks!

    Do you want to raise the input limit above 4000?

  • Custom User Avatar

    Oh wait I lied, I also added 1 extra random test so there is 100, 99 random tests was bothering us.

  • Custom User Avatar

    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.

  • Default User Avatar

    it thinks 0 is all 9's

    something that's nearly as fast: return set(str(x)) == {'9'}

    .. or specialcase 0 I guess

  • Custom User Avatar

    Reading the description should make the condition for m being undefined very obvious.

  • Custom User Avatar

    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).

  • Custom User Avatar

    Case not actually added to most languages as far as I can see.

  • Custom User Avatar
  • Custom User Avatar

    Fixed in CoffeeScript

  • Custom User Avatar

    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.

  • Custom User Avatar

    Bruh who approved it with that in there, fixed.

  • Loading more items...