Below is a link to the "mystery calculator." The user is asked to choose between four and seven cards. Each card displays several different numbers. Next the user is asked to pick a secret number that is on any of the cards. Finally, the user is asked to select all the cards that display that number. The "calculator" then determines the number chosen by the user.
https://eddmann.com/mystery-calculator-clojurescript/
How does this work? Consider the option in which five cards are displayed. The numbers 1 through 31 are shown on the five cards. Most of the numbers appear on more than one card. When the user selects the cards showing their number, each card is either yes-it has my number or no-it doesn't have my number. For five cards there are 2^5 = 32 possible arrangements of yes/no combinations. Therefore there is a unique combination for each of the numbers displayed on the cards. For example the number 1 is only shown on the first card, while 31 is shown on all five cards.
No comments:
Post a Comment