Leilani placed a digit in each of these 16 squares:
+------+------+------+------+
| | | | |
+---- -+------+------+------+
| | | | |
+------+------+------+------+
| | | | |
+------+------+------+------+
| | | | |
+------+------+------+------+
When she had finished, the grid had the following properties:
• No digit occured more than once in any row.
• The sum of the four digits in each row was the same.
• The sum of the four digits in each column was the same.
• Each row formed a different four-digit perfect square.
Complete the 4x4 square grid given above.
Note: Adapted from Enigma #1553 which appeared in 'New Scientist' in 2009.
(In reply to
re(2): Solution by Charlie)
Kenny M, I rechecked my algorithm and it does not check to see if all digits in a column are distinct (in fact they are not all distinct).
The only time the program selects for "no repeat digits" is in the list comprehension definition of the list squares. Squares is used in choosing numbers for the rows.
The only constraint on columns is that the sums of digits are the same.
I have made a correction to my post.
Charlie nailed it; I simply described condition 3 incorrectly.
|
Posted by Larry
on 2023-07-21 11:09:43 |