21
4
Aristotle's number puzzle is the challenge of populating each of 19 cells in a hexagonal grid with a unique integer between 1 and 19 such that the total along every axis is 38.
You can picture the game board looking like this:
And the puzzle, in essence, is the solution to the following set of fifteen equations:
((a + b + c) == 38 && (d + e + f + g) == 38 && (h + i + j + k + l) ==
38 && (m + n + o + p) == 38 && (q + r + s) == 38 && (a + d + h) ==
38 && (b + e + i + m) == 38 && (c + f + j + n + q) ==
38 && (g + k + o + r) == 38 && (l + p + s) == 38 && (c + g + l) ==
38 && (b + f + k + p) == 38 && (a + e + j + o + s) ==
38 && (d + i + n + r) == 38 && (h + m + q) == 38)
Where each variable is a unique number in the set {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
.
There are multiple possible solutions, and are 19!
possible combinations of integers, so naive brute force will be impractical.
Rules:
- No hardcoding the answer or looking up the answer elsewhere; your code needs to find it on its own
- Speed doesn't matter, but you do have to show your results, so code that takes 1000 years to run won't help you
- Find all the answers
- Treat answers that are identical under rotation as identical
- Deduct 5% of your total byte count if you output the results in an attractive honeycomb
- Fewest bytes wins
Great question, looking forward to working a solution to it. – ProgrammerDan – 2014-03-26T03:01:14.570
Do you consider rotated answers as unique? E.g. let's assume a, b, c = 1, 18, 19 indexes a particular solution, if we set c, g, l = 1, 18, 19 and all other values are "rotated" to match, do you consider this a unique solution? – ProgrammerDan – 2014-03-26T03:23:25.263
@ProgrammerDan Rotated answers are identical. I will clarify. – Michael Stern – 2014-03-26T03:27:53.283
1A hexagon has more symmetries than just rotations. What about answers which are identical under a combination of rotaation and reflection? – Peter Taylor – 2014-03-26T08:32:48.317
Interested to see a solution to this one using self-organising maps. – Ant P – 2014-03-26T14:18:06.007
possible duplicate of Code Solution for the Magic Hexagon
– Peter Taylor – 2014-03-27T12:46:43.013@PeterTaylor Might be self-serving, as this question does appear to be a close duplicate, but I believe this is much better described and has a better "win" condition, and other features that highlight it as a better question, and as such should remain open. – ProgrammerDan – 2014-03-27T13:30:56.510
Wondering why an answer with a higher byte count was accepted for code-golf? – bazzargh – 2014-03-31T14:07:20.630
@bazzargh That answer must not have been there when I gave the checkmark, or it was subsequently improved. Or I missed it. Anyway, fixed it now. – Michael Stern – 2014-04-09T17:11:28.330