Ad
  • Custom User Avatar

    You are right. We don't need the "else" statment because the previous "returns". Also, the other friend is right too, the right way to compare string (motivations of this in other answer here) is using the .equals(). I adjusted my solution.

    Also I don't like "if" clausules without curly braces, although the code will have more lines. More clear is better. I adjusted the spacements too :)

    Thank you guys!

  • Custom User Avatar

    It's good solution, but why have you written else statement in the end? Programm will go to command return "green", only if current state wasn't "yellow" or "red".

  • Default User Avatar

    Just solved in C# as well. All looks up and up.

  • Default User Avatar

    Ah I see thank you for explaining it and fixing it. So me using pop() was the problem. I'll keep it in mind that some problems may not play well with mutating an array.

  • Custom User Avatar

    @SinisterSup, your solution supposed to stop when you get exactly on the final square (not paying attention to the snakes/ladders it has), i.e. if on the next turn you get exactly on the final square, you has to return it, ignoring the value of that square (0, snakes or ladders).

    Your code, however, doesn't stop after reaching it, and continues the turns.

  • Custom User Avatar

    "exhausted" means "the array has become empty, and then that empty array has been used for the next test case, although it was supposed to be the same as before the first test".

  • Custom User Avatar

    Even I'm facing the same issue with broken go tests, (11/100), (53/100), (56/100) and (77/100) numbered test are throwing very similar errors, though my code is working properly.

  • Default User Avatar

    Hmm, but I failed the same test case where I was just modifying the board by updating our position in it with an "x". I assumed to solve this we'd need to update one of the parameters... but I suppose that only matters if you're doing it recursively. I coulda just tracked my position with a variable and a while loop or something and it probably woulda been simpler.

    What did you mean by 'exhausted' though.

  • Custom User Avatar

    The reason why your solution didn't pass is because you modified the input array dice, so after the first test in the section it was exhausted.

    Thanks for noting that out, I changed the tests so they won't be modified after each function call, now your solution should pass.

  • Default User Avatar

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

  • Custom User Avatar

    Square all numbers k (0 <= k <= n) between 0 and n.

    It says <= so both are included.

  • Default User Avatar

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

  • Default User Avatar

    Very fun. I encourage more people to try this one!

  • Custom User Avatar

    it's 'another' game, nobody wants to win

  • Default User Avatar

    I think some might be confused if they think in terms of who should win. Solve it as if Frank is having his best day ever and the other two are playing while distracted (probably solving Kata or something).

  • Loading more items...