Hey there all. I've got this assignment (due next Monday!) and I haven't made much headway into it. It's horrible becuase I usually have some idea about how to go about solving the assignments. (If you've read it through already) So far, all I've managed to do is create a list of all five digit primes with a particular sumOfDigits. (i.e. all valid primes to be used in the grid) I just dont know what to do with this now. I've tried using several equations, but that means 12 equations and 24 unknowns. I just can't seem to see any relation between the positions of the grid! Right now I'm even Googling "properties of five digit primes". Help!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Write a program to fill a 5 x 5 grid such that each row (from left to right), each column (from top to bottom) and each diagonal (from left to right) form a 5-digit prime number. The sum of the digits of each prime is the same. For example:
1 1 3 5 1
3 3 2 0 3
3 0 3 2 3
1 4 0 3 3
3 3 3 1 1
Here, the digits of each prime add up to 11. The diagonal primes are 13331 and 34301.
Data consists of two numbers, m and n. The digits of each prime must add up to m and n must be placed in the top-left position. In the example, m = 11 and n = 1.
You may use the same prime more than once in the grid. You must output all possible solutions.
In addition to the above, there are two other solutions for m = 11 and n = 1. They are:
1 1 3 5 1
1 3 3 1 3
1 4 0 3 3
1 3 0 4 3
3 0 3 2 3
and
3 2 3 0 3
5 3 2 0 1
5 0 2 3 1
1 3 3 1 3
1 3 3 3 1