#magic #row #google #trick #jam #card #numbers

app algojam

This is about google code jam

1 unstable release

Uses old Rust 2015

0.1.0 Mar 17, 2017

#4 in #trick

MIT license

21KB
392 lines

RDS

Google Code Jam 2017 Practice in Rust programming language.

problem : 2014 Magic trick problem

This is the solution for magic trick problem in rust programming lagnuage. ###problem : Recently you went to a magic show. You were very impressed by one of the tricks, so you decided to try to figure out the secret behind it! The magician starts by arranging 16 cards in a square grid: 4 rows of cards, with 4 cards in each row. Each card has a different number from 1 to 16 written on the side that is showing. Next, the magician asks a volunteer to choose a card, and to tell him which row that card is in. Finally, the magician arranges the 16 cards in a square grid again, possibly in a different order. Once again, he asks the volunteer which row her card is in. With only the answers to these two questions, the magician then correctly determines which card the volunteer chose. Amazing, right? You decide to write a program to help you understand the magician's technique. The program will be given the two arrangements of the cards, and the volunteer's answers to the two questions: the row number of the selected card in the first arrangement, and the row number of the selected card in the second arrangement. The rows are numbered 1 to 4 from top to bottom. Your program should determine which card the volunteer chose; or if there is more than one card the volunteer might have chosen (the magician did a bad job); or if there's no card consistent with the volunteer's answers (the volunteer cheated).

Dependencies