Joey has to arrange 2N sandwiches which are wrapped by different color wrapper in N pairs such that he can feed his N girlfriends (A hypothetical situation it is where we have to ignore the fact “JOEY DOESN’T SHARE FOOD ”). He has to serve them for 2N-1 Days. Girls don’t like repeated pair of color wrapper of their sandwiches.
Design an algorithm for joey so that for 2N-1 days no pair would be same.
Hint: One can solve problem by using 2*N table.
Here is one of the way to generate 2N-1 sets of different pairs efficiently. For convenience, number the different color from 1 to 2N and place these numbers in a 2N table. The pairs for the first set are given by the columns of this table. To generate the next 2N −2 sets, rotate—say, clockwise—all the entries except 1 in the last generated table.
Figure shows the example for N = 3. The entry 1 is fixed and all other entries are rotated clockwise.
References: The algorithm can be thought of as based on the representation change strategy. Both interpretations of the algorithm outlined above were given by Maurice Kraitchik in Mathematical Recreations [Kra53, pp. 226–227].
This puzzle is contributed by Antara Purohit. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Puzzle 81 | 100 people in a circle with gun puzzle
- Puzzle 83 | Interesting MCQ
- Puzzle 84 | Inverted Matrix
- Puzzle 80 | Tic Tac Toe revisited
- Puzzle 79 | Magical Matrix
- Puzzle | God’s Mercy Graduation
- Puzzle | Bilateral Conversations
- Puzzle | Game of Brussels Sprouts
- Number of Pentagons and Hexagons on a Football
- Check if it is possible to survive on Island