Python Challenge 6
A student has a combination padlock but they do not know the correct combination.
- The pad lock has 4 dials. Each dial has digital 0-9 on it.
- The student has created the program below to run through all the possible combinations that could be correct.
- Run the program to check it works.
from itertools import product
for combination in product([0,1,2,3,4,5,6,7,8,9], repeat = 4):
print(combination)
The student gets some clues to help them narrow down the options for the correct code.
- The first digit is an even number.
- The fourth digit is an odd number.
- The second and third digit total 7 when added together.
- The total of all 4 dials when the combination is correct is equal to 20.
- The first number and the third number are the same.
See if you can build these features into the model to work out the two possibly correct options.