6 kyu

Snakes & Ladders

287 of 1,054dinglemouse
Description
Loading description...
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • sergei-kustov Avatar

    There are snakes at the end of the board in Go tests. I've created a fork that fixes this bug. Could someone approve it?

  • bolones Avatar

    "There are no ladders on the starting square, and there are no snakes on the final square." So why does the random tests have a snakes on the final square? For example: board [0 0 3 0 4 0 0 9 0 0 0 0 0 0 7 0 0 0 0 3 0 0 0 0 0 0 0 -1 0 -4]

  • CAdams747 Avatar

    Hello EPiph,

    In the example I have listed the board is ten (10) squares in length (i.e. - the last index is 9)

    5 (five) + 5 (five) = 10 (ten) and therefore if you are on square 5 (five) and you throw a 5 (five) then you cannot make a move

    I therefore do not consider this issue to be resolved and I maintain my request for yourself to review all of the tests within this challenge

  • CAdams747 Avatar

    Hello,

    Can the author of this challenge please review all of the tests within this challenge

    The answer to the example test should be 9 (nine) but the challenge is seeking the answer of 10 (ten) which, as per the below analysis, I believe to be incorrect


    dice = [2,1,5,1,5,4]

    board = [0,0,3,0,0,0,0,-2,0,0,0]


    Throw #1

    Index at Start of Turn: 5

    Thrown: 2

    Move To Index: 2

    Land On: 3 (a ladder)

    Index at End of Turn: 5


    Throw #2

    Index at Start of Turn: 5

    Thrown: 1

    Move To Index: 6

    Land On: 0

    Index at End of Turn: 6


    Throw #3

    Index at Start of Turn: 6

    Thrown: 5 (a higher number than is needed to reach the final square, so no movement)

    Move To Index: 6

    Land On: 0

    Index at End of Turn: 6


    Throw #4

    Index at Start of Turn: 6

    Thrown: 1

    Move To Index: 7

    Land On: -2 (a snake)

    Index at End of Turn: 5


    Throw #5

    Index at Start of Turn: 5

    Thrown: 5 (a higher number than is needed to reach the final square, so no movement)

    Move To Index: 5

    Land On: 0

    Index at End of Turn: 5


    Throw #6

    Index at Start of Turn: 5

    Thrown: 4

    Move To Index: 9

    Land On: 0

    Index at End of Turn: 9


  • Unnamed Avatar

    Edge case testing is inconsistent between languages. Snakes on the final square appear only in Go. According to the description, this case seems to be valid.

  • KayleighWasTaken Avatar
  • sajadtorkamani Avatar

    This was a fun one, thanks :)

  • Bigoh20 Avatar

    good one :D

  • mauro-1 Avatar
  • Daskye Avatar

    This comment has been hidden.

  • Raxxillion Avatar

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

  • 4500zenja1 Avatar
    • JS fork with upgrading the test framework;

    • Go fork fixing the issue below by akar-0 (link)

  • akar-0 Avatar

    Tests in Go are wrong: they expect one to continue until there is no throw left though one has reached the end:

    board:  [0 0 0 9 0 0 0 0 0 0 -9 -4 0 0 0 0 0 0 0 0 0 0 6 2 0 0 0 -3 0 -3]
    dice:   [2 2 5 4 2 3 4 4 1 2]
    - roll   +2=2
    - roll   +2=4
    - roll   +5=9
    - roll   +4=13
    - roll   +2=15
    - roll   +3=18
    - roll   +4=22
    - ladder +6=28
    - roll   +4=28 (no move possible)
    - roll   +1=29
    - win          (could stop here)
    - snake  -3=26
    - roll   +2=28
    expect: 28
    
  • user6720290 Avatar

    board = [ 0, 2, 0, 0, 0, -2, 0, 0, 0, 0 ] dice = []

    Expected output is 6?

  • Daywalker654 Avatar

    What means No Dice?

  • sobodmi Avatar

    Go random tests do not seem work properly. In a case, when "could stop here". My code ran directly returns "actual" result rather than "expect"

    ....

    • roll +1=29
    • win (could stop here)
    • snake -3=26
    • roll +2=28 expect: 28 actual: 29
  • KataSideKick Avatar

    C# Translation added.Please review and approve~

  • user5036852 Avatar

    Nice kata!

  • dinglemouse Avatar

    @gabbek thanks for approving :-)

  • akrammon Avatar

    I really enjoyed solving this Kata. Also, I think it is fine in context of the story that certain checks are not needed (for example starting with snake, ending with ladder, letting a snake move us before the initial position etc.)

    Perhaps in a future Kata we could write a function that generates a valid board? :)

  • max30272 Avatar

    I like Snakes & Ladders.When I was a child,I always play this kind of board game by myself.(Because no friends) If the board is 2-dimension would be better.Because it's a board not a line. Otherwise this is a good kata.

  • JohanWiltink Avatar

    There is no reason why the board couldn't start on a ladder or end on a snake (making it unwinnable), or why a ladder or snake couldn't end on a ladder or a snake. They're perfectly reasonable edge cases.

    This would invalidate some solutions, including your own :P but the board remains decidable.

  • dinglemouse Avatar