Ad
  • Custom User Avatar
  • Custom User Avatar

    ball_test(2, xx___xx_x_xx_x_x_xxx____x______xxx_x_x_xxx____x_____x____x__xx____x_xxxx_xxx__x__x_xx___x___x__x__x_x_x___x______) should be true

    Really ?

    Edit: Refreshing the page and continuing to test the SAME code eventually resulted in some random tests that my code could pass.

  • Custom User Avatar

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

  • Custom User Avatar

    fixed

  • Custom User Avatar

    If a ball happens to roll over a crack, the speed decrease must only take effect after the ball has rolled a distance equal to its speed.

    Distance can never be equal to speed even though both are scalar numbers which can be the same number. They are different dimensions/units related by another dimension/unit, time. The description can make much more sense if you specify that speed is distance-units-per-second. Then you would say "For every second the ball rolls, and for every crack over which it rolls, its speed decreases by 1 unit/second" and "the speed decrease must only take effect at the end of each second."

  • Custom User Avatar

    #include <stdbool.h> is missing in the initial code in C

  • Custom User Avatar

    Awful kata requiring mind-boggling special casing until you hit the right 'spot', due to its poor description and dubious interpretations.

  • Custom User Avatar

    ballTest(5, 'xxxxx')); being true bothers me; I think it should be false.
    Spec says
    'return whether or not the ball will be able to make it past the end of the road'
    'The ball must fall off of the edge of the road for the code to be considered valid.'
    The speed at the end of the road is -1, the ball is stuck on the 5th crack, never to make it past the end of the road.

  • Custom User Avatar

    Terrible details.

  • Custom User Avatar

    You're correct thank you for the feedback! The description has been changed

  • Custom User Avatar

    The last tile has index roadmap.length - 1 though (as strings are zero-indexed), so if the position is roadmap.length, the ball will already have passed the final tile.

  • Custom User Avatar

    I am not sure I understand completely what you are trying to say but I will attempt to explain. In your snippet, the program is checking (currentPosition >= roadmap.length) which does not imply that the ball has passed the final tile. It only means that it has reached the final tile. To check if it has passed, you must check (currentPosition > roadmap.length) instead. So the correct solution would use the example shown, meaning that the ball did not necessarily pass the final tile, but may have only reached it instead.

  • Custom User Avatar

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

  • Custom User Avatar

    approved by author

  • Custom User Avatar

    #include <stdbool.h> is missing in the initial code

  • Loading more items...