0
$\begingroup$

I'd like to populate a "tic tac toe" board (grid of 3 x 3 squares) with four appropriate entries at which time a user will attempt to solve. I'm having a hard time coming up with a mathematical solution to creating the four initial entries.

A picture is worth a thousand words so here is a picture of one particular initial setup and solution.

I'm making a web-based game for my kids that encourages them to learn the basics of algebra. The game and source code (Action Script 3) will be available on my action script note page.

I can come up with something that uses brute force to figure out solutions but I'm hoping there is an elegant mathematical solution I can utilize.

  • 0
    You want to create a magic square, right?2012-04-18

1 Answers 1

1

I think, as Peter comments, that you are trying to construct magic squares, that is, $3\times3$ arrays of positive integers such that all the row, column, and diagonal sums are equal. All such squares can be obtained from $\matrix{a+(b-c)/2&a+c&a-(b+c)/2\cr a-b&a&a+b\cr a+(b+c)/2&a-c&a-(b-c)/2\cr}$ by putting in integers for $a,b,c$. You need $a\gt|b|$, $a\gt|c|$, and $b$ and $c$ must either both be odd or both even. For example, the choice $a=5$, $b=2$, $c=-4$ will give you $\matrix{8&1&6\cr3&5&7\cr4&9&2\cr}$

  • 0
    Will do, thanks!2012-04-28