Ashish was admiring the output of his new program to generate random number. He had printed out the first ten numbers of the results. He soon noticed that each of the ten numbers had exactly one digit, in the proper placement, of the 5 digit code he used to open his car door without a key. Find Ashish's car entry code from these first 10 randomly generated numbers : . Ashish has announced that he will give his car to that person who will crack the key number.
Explicit Example: if Ashish's key code is 12345(obviously not the solution), then a randomly generated number will be such that, one and only one of its digit will match with the car key. Suppose the number generated is 54321. Now this number has 3 which matches with the car keys. Another number say 12543, has 2 as the matching digit.
Second Explicit Example: In the fist number 14073, Ashish's car code could not be 34170(two digits correctly placed(4 and 7)) or 92365 (none).
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
@Ashish Siva when can I pick up my car?
Now, imagine if the code is 1 2 3 4 5 , and the 1 0 generated numbers are like this:
1 9 9 9 9 , 1 9 9 9 9 , 9 2 9 9 9 , 9 2 9 9 9 , 9 9 3 9 9 , 9 9 3 9 9 , 9 9 9 4 9 , 9 9 9 4 9 , 9 9 9 9 5 , 9 9 9 9 5
We can see that each digit of the actual code should appear on 2 generated numbers on average
Now, notice that for the 1 0 generated codes:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
The first digit of the codes are all different, which implies that only 1 number has the correct first digit. This in turn implies that one of the digits in the correct position appears on 3 distinct generated numbers. We check for this, and find two possible cases:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
Either the 3 rd number is 1 , or the 4 th number is 7 . No other method, we gotta do a case by case analysis
Case 1: 3 rd number is 1
Now, we know that the 4 th number cannot be 7 . This implies that the remaining correct digits each appear in 2 distinct numbers. We check the 5 th digit for such a number:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
We have two possibilities: 1 or 2
Suppose that the 5 th digit is 1 :
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
The remaining 3 rd digits are all distinct, therefore this combination is not possible
Instead, we try 2 as the 5 th digit:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
Similarly, the remaining 3 rd digits are all distinct, therefore this combination is not possible too.
We can conclude that Case 1 is not possible, and the correct answer lies in Case 2
Case 2: 4 th number is 7
The 3 rd number cannot be 1 , and the remaining digits appear in two numbers each. We repeat the same steps earlier:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
It can be 2 or 6 .
We test the number 2 first:
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
The remaining 2 nd digits are all distinct, therefore this combination is not possible
Therefore, we know that the 5 th digit must be 6
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
From here, we can decude the remaining digits. The 2 nd digit must be 9 , and the 3 rd digit must be 8 . This leaves us with 3 as the 1 st digit
1 4 0 7 3 , 7 9 5 8 8 , 0 5 8 9 2 , 8 4 7 7 1 , 6 3 1 3 6 , 4 2 9 3 6 , 3 7 1 4 5 , 5 0 8 1 1 , 9 8 1 7 4 , 2 9 4 0 2
Ashish's car entry code is 3 9 8 7 6