Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Perhaps my description of the kata will make more sense:
Description
Amidakuji is a lottery method designed to create random pairs between two sets of the same size.In this kata the elements of the first set are whole numbers from 0 to 6. Your task is to write an
amidakuji
function that returns second set comprised of converse numbers.Input
Your function will receive an array of equal-length strings consisting of 0 and 1 characters; this represents the "ladder" structure. The
1
represent the rungs of the ladder and the0
represent empty space.Take a look at the diagram below:
Row
0
of the ladder is'001001'
string, which means there will be two horizontal bridges at this row; one between the vertical lines 2 and 3 and another between vertical lines 5 and 6. When proceed to move down vertical lines, a transition is made to the adjacent vertical line over the nearest bridge.Output
The diagram above is a visual representation of
ladder
argument of the function.At the top of the diagram the 2 has a third position, in the aftermath of the ladder it got a second position. The yellow highlighted path shows the path taken by the 2 value. Every time it encounters a bridge, it moves to the opposite vertical line.
Your function should return an array of numbers, with each number in its final position.