Gamified challenge · Asked in Capgemini
A row of symbols passes through two switches that shuffle it. A switch's code is a string of the digits 1 to n: output position i takes the input symbol at position code[i] - 1, so code 2134 turns ABCD into BACD. You know the top row, the first switch's code and the bottom row that comes out of the second switch.
Write secondSwitch(top, first, bottom) (second_switch in Python) that returns the second switch's code. For "ABCD", "2134", "CBAD" the first switch gives BACD, so the answer is "3124".
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google