Ponder This

Welcome to our monthly puzzles.
You are cordially invited to match wits with some of the best minds in IBM Research.

February 2025 - Challenge

<< January


Given a number A , we wish to construct an N\times N square of digits (0,1,2,3,4,5,6,7,8,9) such that

      1. The sum of each row, column, and diagonal is A .
      2. The number appearing in each row (left-to-right), column (top-down), and diagonals (top left to bottom right and top right to bottom left) is an N -digit prime number (no leading zeros).

Note that the same digit can appear multiple times in the square, and the same prime number can appear multiple times in the square.

The cost of a square is computed in the following manner: We list all the prime numbers appearing in the rows, columns, and diagonals of the square. We remove any duplicates from the list. For each digit d , we count the total number of times it appears in the primes in the list. Each time incurs a cost: the first time the cost is 0, the second time it's 1, the third time it's 2, and so on. Note that the same digit in the square appears in more than one number and hence might be counted more than once; we count the occurrences of the digits in the prime numbers, not in the square itself.

For example, for N=4 we have the following square:

1 7 7 7
5 5 5 7
9 3 9 1
7 7 1 7

in which A=22 and which contains the unique primes 7717, 9391, 5557, 7591, 7537, 1597, and 1777. The square has a total of 5 occurrences of the digit 1, 2 of the digit 3, 6 of the digit 5, 11 of the digit 7, and 4 of the digit 9, resulting in a cost of 87 in total. This is the 4\times 4 square with minimum cost. Similarly, the 4\times 4 square of maximum cost is

5 7 9 1
1 7 7 7
7 5 3 7
9 3 3 7

which has a cost of 143.

Your goal: For N=5 , find the squares of minimal cost and maximal cost (without limiting A to A=22). Provide your squares as written above, with the score of each square written above it.

A bonus "*" will be given for finding squares of minimal and maximal costs for N=6 .


We will post the names of those who submit a correct, original solution! If you don't want your name posted then please include such a statement in your submission!

We invite visitors to our website to submit an elegant solution. Send your submission to the ponder@il.ibm.com.

If you have any problems you think we might enjoy, please send them in. All replies should be sent to: ponder@il.ibm.com

 

Challenge: 02/02/2025 @ 10:00 AM EST
Solution: 05/03/2025 @ 12:00 AM EST
List Updated: 04/02/2025 @ 11:55 AM EST

Yi Jiang(2/2/2025 4:33 PM IDT)
Lazar Ilic(2/2/2025 7:27 PM IDT)
King Pig(2/2/2025 7:30 PM IDT)
Gary M. Gerken(2/2/2025 9:45 PM IDT)
Ankit Aggarwal(2/2/2025 10:07 PM IDT)
Harald Bögeholz(2/2/2025 10:22 PM IDT)
Sanandan Swaminathan(2/2/2025 10:22 PM IDT)
Daniel Chong Jyh Tar(3/2/2025 1:32 AM IDT)
Károly Csalogány(3/2/2025 4:44 AM IDT)
*Bertram Felgenhauer(3/2/2025 5:37 AM IDT)
Alper Halbutogullari(3/2/2025 10:26 AM IDT)
Alex Fleischer(3/2/2025 1:04 PM IDT)
Sam Fischer(3/2/2025 5:01 PM IDT)
Ralf Jonas(3/2/2025 10:00 PM IDT)
Noam Zaks(3/2/2025 10:12 PM IDT)