# It cannot be done. I think

I have spent too much time on this question. I am convinced this cannot be done. Please prove me right (or wrong) and explain why.

Below is a 5x5 grid. Digits 1 through 9 go in the 9 yellow boxes. Every digit must be used. Yellow boxes can only contain a single digit, nothing else.Obviously all 9 digits will have to be placed.

Bluish boxes will have the givem Math operators. Only + - * / ^ and = can be used. Nothing else.

Now can a grid be created where all vertical, horizontal and diagonal equations are correct? Direction of the equation not important.

I tried and tried and failed. The closest I came was

I got horizontals, diagonals and two of the 3 verticals to work but not the middle.

Can this be done given the restrictions? Why?

Which operators will make this possible, if any.

Please don't say "not equal to" :)

• fun problem, but just wondering where it came from or if you are trying to make up a puzzle. – tom Mar 18 '20 at 13:18
• All my puzzle @tom. I have too much time at hand. BTW I am serious when I say it probably cannot be done. – DrD Mar 18 '20 at 13:19
• Congrats on 20k reputation! – Rand al'Thor Mar 18 '20 at 14:11
• I did not find a solution by brute force permutation, but I did not finish proving it logically. For that, I began by trying each number in the centre, and then 9 can go in one of two locations, and I could not complete any arrangment. Sadly I gave up at 4, because presenting every attempt exhaustively isn't much fun ;) One point of interest is rot13(gurer jnf ab arrq gb purpx qvivfvba, orpnhfr vg vf pbirerq ol gur erirefr zhygvcyvpngvba). – Weather Vane Mar 18 '20 at 14:55
• You could place two plus signs there. – daw Mar 18 '20 at 15:29

### Using only basic operators (+ - * / ^)

It is not possible but there are many solutions that are missing a single row/column.

This Python program would print all complete solutions if any existed: https://repl.it/repls/OrchidAcceptableNaturaldocs

There are 16 solutions that, like yours, are missing the center column:

There are 64 boards total that are missing any one row, column, or diagonal.

Here is the complete list: https://pastebin.com/dSAnwQhB

and here is the generating code: https://repl.it/repls/BriefWarmInstitutions

### If we were to introduce bitwise operators

There are 24 possible solutions, one of which being:

Generating code: https://repl.it/repls/AuthorizedCriminalPagerecognition

Including only OR: 8 boards
Including OR and AND: 24 boards

### Including Square Root, Square, and Factorial operations

There are 46 complete boards that involve at least one of sqrt, square, and factorial

For example:

Example with factorial:

Generating code: https://repl.it/repls/WhoppingIncompleteApplicationframework

• Great effort. IF you allow certain operators within the number boxes like ! or Square or square root so you change the numbers themselves it could be possible, right? – DrD Mar 19 '20 at 12:44
• @DEEM There definitely are solutions if you allow sqrt, square, and factorial (likely hundreds). I've found several and hope to have a complete list soon. – DenverCoder1 Mar 19 '20 at 14:40
• @DEEM Here is an example – DenverCoder1 Mar 19 '20 at 15:15
• That is great. So there is a Magic square with 1 to 9!! – DrD Mar 19 '20 at 15:28

I used integer linear programming to verify that the problem is infeasible. It turns out that there are 64 near misses with one violation like yours. These reduce to 8 solutions up to symmetry:

 143
752
896

143
792
658

165
739
824

176
832
954

263
459
817

263
781
594

263
945
718

263
954
817