A B C D E
+-----+-----+-----+-----+-----+
| | | | | |
| 1 | 7 | 13 | 20 | 6 |
+-----+-----+-----+-----+-----+
| | | | | |
| 25 | 9 | 2 | 23 | 11 |
+-----+-----+-----+-----+-----+
| | | | | |
| 14 | 22 | 17 | 8 | 16 |
+-----+-----+-----+-----+-----+
| | | | | |
| 4 | 12 | 10 | 3 | 19 |
+-----+-----+-----+-----+-----+
| | | | | |
| 24 | 18 | 5 | 15 | 21 |
+-----+-----+-----+-----+-----+
Add together five different numbers from the grid above to achieve the highest possible total. Starting at column A and working your way across to column E, only one number may be chosen from each column, and no two
numbers may be from the same row or diagonal line.
(In reply to
Conflict? by brianjn)
The program doesn't check for being in the same diagonal line.
Compare to my program:
IF col - c = ABS(r - h(c)) THEN good = 0: EXIT FOR
If the row distance equals the column distance for any of the previous columns (my program works by column), the addition of the new element is rejected.
|
Posted by Charlie
on 2013-05-21 23:14:39 |