Apologies for the cross post in both Maths and Programming, but it really is a cross-disciplinary problem.
A friend of mine has given me this problem and it really is wrecking my head. I have a list of 22 distinct 16 digit numbers. They hold within them the clues to one true solution to the code, i.e. the single correct thirteen digit number. My clues are as follows. The number of correct digits for a given code indicates how many digits within that example are correct.
x0: 0 correct digits
x1 - x6: 1 correct digit
x7 - x13: 2 correct digits
x15 - x21: 3 correct digits
For example, a line may be:
3248975391044454 with 2 correct digits
So, let's just assume it's the first two which are correct, the correct code will be:
32ABCDEFGHIJKLMN where A - N are other digits.
I'm absolutely lost trying to find a decent algorithm which will let me solve this question. He assures me that the correcgt algorithm will find a solution in less than twenty minutes on any modern computer. I've been using Python to try and solve the problem.
I cannot devise an algorithm which will allow me to eliminate numbers from each position. I had something I thought would work which basically ran like this:
Guess first X digits from row 1 where X is the number we have been told are correct in row 1
Guess first Y digits from row 2 where Y is the number we have been told are correct in row 2
And so on, until EITHER:
1. Guess is complete and we have our solution
2. Guess cannot go any further (for example, gets to row [i]M[/i] and there are no possible correct values left, where 0 < [i]M[/i] < 20)
My problem lies in the fact that more often than not, we'll get to scenario two as the guess will break unless we are very lucky during our first run... however, when the guess does break, what exactly does this tell me? Was the first number I placed in the guess incorrect? Is the very last number I've guessed? Can I say anything EXCEPT that the EXACT sequence of numbers I have guessed is incorrect? - This seems very brute forcish for something supposedly elegant.
Does anyone have any tips or references I could take a look at? If there's not much interest but anyone really does want to try and tackle this with me, I'm always availabile at
rob@robburke.ie but let's try and get a good thread going first!