Ad
  • Custom User Avatar

    Thanks for the reply. I realized that I misunderstood your solution.

         input: [0, 1, 2, 3, 4, 5, 6]
         left:  [4, 3, 2, 1, 6, 5, 0]  // mine
         right: [6, 3, 2, 1, 0, 5, 4]  // solution
    

    I got the result after transition but not the position array.

    I made it!

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    It can be described as a shuffle as well, but that particular wording used in the Description was taken verbatim from the Wikipedia page; that page provides the historical context -- it was a method of lottery used to assign things like chores or prizes. Think of it like the game of drawing straws.

    Also, added some clarity to the Description:

    During the descent of the ladder, whenever a vertical rail intersects a horizontal rung, it swaps values with the adjacent connecting vertical rail.

  • Custom User Avatar

    Amidakuji is a method of lottery designed to create random pairings between two sets comprised of an equal number of elements.

    I'd describe it as a shuffle, rather than a lottery. It doesn't seem to create pairings between two ( possibly different? ) lists; it just shuffles its input list.

  • Custom User Avatar

    How can 0 become 6, I thought it should be 4.

    If we follow the path of the 6, we see it ends up at the 0 position, below:

    EDIT: pasted an image because the Discourse section, though it renders HTML code fine in the preview, will not show it as the actual comment.
    EDIT #2: Each index value of the returned list/array should be occupied by the number that arrives at that position. The '6' value, after swapping all of its positions, arrives at the 0 index slot.

  • Custom User Avatar
    | | | | | |_|
    | |_| | |_| |
    |_| |_| | |_|
    | |_| |_| | |
    | | |_| |_| |
    | |_| | | | |
    |_| | | |_| |
    | |_| |_| | |
    

    How can 0 become 6, I thought it should be 4.
    [down down right right right down down right]
    And 6 becomes 4?
    [left left down left left left left down]

  • Custom User Avatar

    Learn some math guys, no space occupied, operate in O(n) time.