Ad
  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    Sorry for the slow response. Please see my answer to bonhart67 👍

  • Custom User Avatar
  • Custom User Avatar

    can you explain the thought process behind this solution?

  • Custom User Avatar

    Nice! I'm no guru on regex and hadn't been able to identify what was going wrong. You've helped me learn something, so cheers for that : )

  • Custom User Avatar

    Yes, you're absolutely right! My code is wrong.
    I remember being a bit annoyed by the opinionated tests, so I might have taken a shortcut there.
    That's a sin of course, sorry for that ;-)

    At a glance, the two things that might be the issue here are:

    • Not clamping my regular expression with ^......$, making my regular expression a check to see if an IP-adres is somewhere within the provided string, instead of checking that the full string is following the IP-address format. That is what makes 07.1.1.1 valid, since the 0 is ignored by the regex.
    • making the number format [1-9]\d{0,2}, which says that the first number in an octet should always be 1 - 9. That is what breaks 127.0.0.1 here, since that one shows that a 0 is a perfectly fine number as well.
    • I can't really explain 08.1.1.1 right now, but I'll create a new iteration in a minute, in which I test that case as well.

    Thanks for your comment, much appreciated!

  • Custom User Avatar

    Seems as though something's not quite right here. For example, the code results in "07.1.1.1" being valid, but "08.1.1.1" is not.

    "127.0.0.1" is not valid either, although that could be blamed on the poor quality of the description and test cases given for the exercise.

  • Default User Avatar

    I'm not sure if understand the Kata correctly or if there is an error.
    After running the test for submission, I had these failed tests:

    Some random tests
    ✘ Line = 100,25,25,25,100,25,50,25,100,25,50,25,100 - Expected: YES, instead got: NO
    ✘ Line = 100,25,25,25,100,25,25,50,100 - Expected: YES, instead got: NO
    ✘ Line = 100,25,25,25,100,25,25,25,100,25,50,25,100,25,25,50,100 - Expected: YES, instead got: NO
    ✘ Line = 100,25,25,25,100,25,25,50,100,25,25,50,100 - Expected: YES, instead got: NO
    ✘ Line = 100,25,25,25,100,25,25,50,100 - Expected: YES, instead got: NO
    ✘ Line = 100,25,25,50,100,25,25,25,100,25,25,50,100 - Expected: YES, instead got: NO

    If Vasya has no money to start and a ticket costs $25, how can he give change if the first person pays with $100?

  • Custom User Avatar

    The set of test cases for this kata need tightening up. I've found a number of published solutions that should not have been allowed to pass.

    one C# solution, which has been marked up as being 'clever', even fails to pass the simple test [25, 50] => "YES".

    Another published solution I found doesn't take into account the instruction to "sell the tickets strictly in the order people follow in the line" and fails the test [25, 25, 25, 100, 50, 50, 100, 25] => "NO".

    Kata validation tests should properly reflect all given requirements.

  • Custom User Avatar

    This code fails for even the simplest test: [25, 50] => YES

    The set of test cases needs fixing on this kata!