Let the 4-digit ATM pin code be represented by the digits
abxy, where all digits are different, the greatest digit is 7, and the sum of the first two digits is equal to the sum of the last two digits:
a+b=x+y.
Since the greatest digit is 7, the possible digits for the pin code are
0,1,2,3,4,5,6, and
7.
1. Let's denote the sum of the first two digits and the sum of the last two digits as
λ. Since the largest digit is 7, we can analyze different possible values for
λ.
We will analyze different possible values for
λ and the corresponding possible pairs of digits:
-
λ=7: The pairs of digits that have a sum of 7 are
(0,7),(7,0),(1,6),(6,1),(2,5),(5,2),(3,4),(4,3). Since 7 must be present, we consider the pairs with 7:
(0,7),(7,0).
When the pair
(0,7) is chosen, the other two digits can be any one of the remaining pairs:
(1,6),(6,1),(2,5),(5,2),(3,4),(4,3). For each of these pairs, there are 2 possible pin codes:
07xy and
07yx, where
x and
y are the digits from the chosen pair. In total, there are 12 possible pin codes for this case.
When the pair
(7,0) is chosen, the other two digits can also be any one of the remaining pairs:
(1,6),(6,1),(2,5),(5,2),(3,4),(4,3). For each of these pairs, there are 2 possible pin codes:
70xy and
70yx, where
x and
y are the digits from the chosen pair. In total, there are 12 possible pin codes for this case.
So, there are 24 possible pin codes for
λ=7.
-
λ=8: The pairs of digits that have a sum of 8 are
(1,7),(7,1),(2,6),(6,2),(3,5),(5,3). Since 7 must be present, we consider the pairs with 7:
(1,7),(7,1).
When the pair
(1,7) is chosen, the other two digits can be any one of the remaining pairs:
(2,6),(6,2),(3,5),(5,3). For each of these pairs, there are 2 possible pin codes:
17xy and
17yx, where
x and
y are the digits from the chosen pair. In total, there are 8 possible pin codes for this case.
When the pair
(7,1) is chosen, the other two digits can also be any one of the remaining pairs:
(2,6),(6,2),(3,5),(5,3). For each of these pairs, there are 2 possible pin codes:
71xy and
71yx, where
x and
y are the digits from the chosen pair. In total, there are 8 possible pin codes for this case.
So, there are 16 possible pin codes for
λ=8.
-
λ=9: The pairs of digits that have a sum of 9 are
(2,7),(7,2),(3,6),(6,3),(4,5),(5,4). Since 7 must be present, we consider the pairs with 7:
(2,7),(7,2).
When the pair
(2,7) is chosen, the other two digits can be any one of the remaining pairs:
(3,6),(6,3),(4,5),(5,4). For each of these pairs, there are 2 possible pin codes:
27xy and
27yx, where
x and
y are the digits from the chosen pair. In total, there are 8 possible pin codes for this case.
When the pair
(7,2) is chosen, the other two digits can also be any one of the remaining pairs:
(3,6),(6,3),(4,5),(5,4). For each of these pairs, there are 2 possible pin codes:
72xy and
72yx, where
x and
y are the digits from the chosen pair. In total, there are 8 possible pin codes for this case.
So, there are 16 possible pin codes for
λ=9.
-
λ=10: The pairs of digits that have a sum of 10 are
(3,7),(7,3),(4,6),(6,4). Since 7 must be present, we consider the pairs with 7:
(3,7),(7,3).
When the pair
(3,7) is chosen, the other two digits can be any one of the remaining pairs:
(4,6),(6,4). For each of these pairs, there are 2 possible pin codes:
37xy and
37yx, where
x and
y are the digits from the chosen pair. In total, there are 4 possible pin codes for this case.
When the pair
(7,3) is chosen, the other two digits can also be any one of the remaining pairs:
(4,6),(6,4). For each of these pairs, there are 2 possible pin codes:
73xy and
73yx, where
x and
y are the digits from the chosen pair. In total, there are 4 possible pin codes for this case.
So, there are 8 possible pin codes for
λ=10.
-
λ=11: The pairs of digits that have a sum of 11 are
(4,7),(7,4),(5,6),(6,5). Since 7 must be present, we consider the pairs with 7:
(4,7),(7,4).
When the pair
(4,7) is chosen, the other two digits can be any one of the remaining pairs:
(5,6),(6,5). For each of these pairs, there are 2 possible pin codes:
47xy and
47yx, where
x and
y are the digits from the chosen pair. In total, there are 4 possible pin codes for this case.
When the pair
(7,4) is chosen, the other two digits can also be any one of the remaining pairs:
(5,6),(6,5). For each of these pairs, there are 2 possible pin codes:
74xy and
74yx, where
x and
y are the digits from the chosen pair. In total, there are 4 possible pin codes for this case.
So, there are 8 possible pin codes for
λ=11.
-
λ=12: The only pair of digits that have a sum of 12 is
(5,7). Since 7 must be present, this case is not possible.
-
λ=13: The only pair of digits that have a sum of 13 is
(6,7). Since 7 must be present, this case is not possible.
-
λ=14: The only pair of digits that have a sum of 14 is
(7,7). Since all the digits must be different, this case is not possible.
Adding up all the possible pin codes for each value of
λ, we get:
16+24+24+16+8=72
Therefore, the maximum number of trials necessary to obtain the correct code is 72.