Archaeologists had found a coffer containing jewelry. Unfortunately, the coffer has a code, which is a digit (from to ). After every wrong attempt, the code increases by one (if the code was , it changes to ). If you try the same digit twice (at any point in time), the coffer explodes.
Is it possible that we can always open the coffer?
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.
i interpret the problem as follow:
the code can be a single digit 0~9.
you cannot input same number twice. as a consequence, you can input at most 10 times. (0~9)
every wrong attempt, the code cycles from 0~9 and back to 0.
under worse case scenario, is there a guaranteed way to enter the correct code?
the answer is no. here is the reason.
notice that in worse case scenario, we need input at least 10 times. hence, we focus on eliminating the possible code at last (10th) attempt.
during 1 st attempt, say we input 3 and its wrong, then last attempt the code is not 3 - 1 = 2 . we know this by tracking incorrect input 3 cycling through 4~9 and 0~2.
during 2 nd attempt, say we input 0 and its wrong, then last attempt the code is not 0 - 2 == 8 (mod 10) by same reasoning.
in general, during n -th attempt, we input a and its wrong, then last attempt the code is not (a-n) mod 10 .
let a n be the input during n-th attempt, let b n be the eliminated code on last attempt. so the examples in step 2 and 3 translate into: a 1 = 3 , b 1 = a 1 − 1 = 3 − 1 = 2 a 2 = 0 , b 2 = a 2 − 2 = 0 − 2 ≡ 8
during last attempt, we wish to "cover" all cases. the goal is to find a n = 0 ∼ 9 and b n = 0 ∼ 9 such that a n − n ≡ b n ( mod 1 0 ) for n = 1 ∼ 1 0
assume this can be done, we sum up b n on one hand, ∑ b n on the other hand, ∑ b n ∴ ∑ b n ≡ 5 ≡ 0 ( mod 1 0 ) = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 4 5 ≡ 5 ( mod 1 0 ) = ∑ ( a n − n ) = ∑ a n − ∑ n = 4 5 − 5 5 = − 1 0 ≡ 0 ( mod 1 0 )
we arrive a contradiction, hence there is no guarantee way to enter the correct code.