Question
You get a job as a magicians assistant. One magic trick that the magician has in their show the the Secret Digit. In this trick
You get a job as a magicians assistant. One magic trick that the magician has in their show the the "Secret Digit". In this trick the magician brings an audience member onto the stage. He then:
1. Asks then to think of 4 digits (keeping them secret)
2. Asks them to make two numbers with those digits (keeping them secret)
3. Asks them to subtract the smaller number form the larger number (keeping the result secret)
4. Asks them to choose any digit in the difference except 0 (keeping it secret)
He then asks the audience member to tell him the remaining three digits and "magically" tells the audience member the missing digit from step 4 above.
What the magician does not tell the audience is that you can talk to him through a hidden earpiece and that you tell him the missing digit.
In this assignment you are to write a program that will calculate the missing digit so you can communicate it to the magician.
Sample Input/Output
Example #1:
1
9
9
The missing digit is: 8
Example #2:
5
7
8
The missing digit is: 7
Example #3:
4
2
1
The missing digit is: 2
I know that this assignment can be a bit confusing:
Let's walk through the steps as if we were playing this game in person:
- I think of a 4 digit number, let's assume I think of 1234
- I think of two combinations of the digits in that number, let's assume I think of 4132 and 2134
- I subtract the smaller from the larger (4132-2134) that gives me 1998
- I tell you any three of the digits in that number, let's assume I tell you 1, 9, 9
- You tell me that the missing digit is 8
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To solve this problem we need to understand the properties of the difference between two numbers tha...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started