Problem #6
Combination Lock
You have a lock which requires 4 numbers be entered to open it, but you have forgotten
the last two numbers that you need to enter. The dial is marked with the counting numbers from 0 up 19, so if you tried to guess the forgotten numbers of your combination by brute force it would require 20 times 20 = 400 attempts to have tried every combination, or about 200 tries on average, and then it might be cheaper to just throw away the lock.
Fortunately, you think you have remembered some facts about your combination which should help you reduce the number of tries you need:
The sum of the four numbers is greater than or equal to 60.
At least one of the numbers in the combination is odd.
At least one of the numbers in the combination is even.
When divided by five, the first number of the combination had the same remainder as the fourth number when divided by five.
When second and third numbers of the combination were each divided by 5 each also had the same remainder.
Write a program that will read the first two numbers of the combination, and print out all the combinations that satisfy the above rules followed by the number of combinations that were printed in the manner shown below:
sample run #1
Enter the first two numbers: 16 19
Result: 16-19-9-16
Result: 16-19-14-11
Result: 16-19-14-16
Result: 16-19-19-6
Result: 16-19-19-11
Result: 16-19-19-16
Result: Total: 6 Possible combination(s)
sample run #2
Enter the first two numbers: 11 12
Result: Total: 0 Possible combination(s)
sample run #3
Enter the first two numbers: 10 20
Result: 10-20-15-15
Result: Total: 1 Possible combination(s)
sample run #4
Enter the first two numbers: 15 19
Result: 15-19-14-15
Result: 15-19-19-10
Result: Total: 2 Possible combination(s)