# Secret 3x3 square

I have a 3x3 square filled with numbers. You can select a sub-rectangle^ and I will tell you the sum of all the numbers inside that rectangle. The penalty for doing this is $$10-X$$, where $$X$$ is the area of the selected sub-rectangle. How can you find all the numbers while incurring the smallest total penalty?

^ Note the sub-rectangle can be square.

• Are the secret numbers unique, or can there be duplicates?
– Bass
Nov 16, 2021 at 12:26
• There can be duplicates. But if you have a nice solution that assumes uniqueness then please post it too! Nov 16, 2021 at 12:40

I think the best penalty we can do is

41

Reasoning

To determine nine unknown numbers requires nine linearly independent simultaneous equations, so I need to ask about nine sub-rectangles. The best way to optimize the penalty is then to pick the largest subrectangles I can and hope that the associated equations are linearly independent.
I can first pick the whole 3x3 square, then each of the four possible 2x3 (or 3x2) subrectangles, then each of the four possible 2x2 squares.
Luckily, Wolfram alpha tells me that the associated matrix for this linear system has non-zero determinant so this will allow me to compute all the numbers.
The total penalty is, therefore, $$(10-9) + 4\cdot(10-6) + 4\cdot(10-4) = 41$$

• Very nice! Does this work in all cases, eg. if all numbers are 0? Nov 16, 2021 at 13:38
• It reminds me a bit of Rubik's Clock. Nov 16, 2021 at 13:41
• @DmitryKamenetsky For an explicit calculation, you can use $a = (abcdefghi-defghi)-(bcefhi-efhi)$ for a corner cell, and $b = (abdegh-degh)+(bcefhi-efhi)-(abcdefghi-defghi)$ for an edge cell, where the cells are labelled $a$ to $h$. The other corner and edge cells are found similarly by symmetry. Nov 16, 2021 at 14:14
• I came up with a solution with a larger penalty than hexomino so I was curious to see their solution. Turns out mine was the same! I think hexomino has made an error in the penalty calculation: >!the 2x2 rectangles should contribute a penalty of 6 (not 5). I would have made this a comment, but I have insufficient reputation. Nov 16, 2021 at 21:28
• @JaapScherphuis: Extending that, the center cell is (I believe) the $3 \times 3$ sum, plus the sums of all four $2 \times 2$ rectangles, minus the sums of all four $3 \times 2$ rectangles. Nov 17, 2021 at 16:47