title: 3x3 magic square with unknown magic constant (sum)
body: <p>I am trying to fill missing fields in a 3x3 matrix (square) in order to form a magic square (row, columns both diagonals sum are the same, filled with any none repeating positive integers ).
  an example of such square will be like :</p>
  <pre><code>[_ _  _]
  [_ _ 18]
  [_ 28 _]
  </code></pre>
  <p>Since it doesn't follow the basic rules of the normal magic square where its integers are limited to 1-9(from 1 to n^2). , the magic constant (sum) is not equal to 15
  (n(n^2+1)/2) rather it's unknown and has many possible values.</p>
  <p>I tried a very naïve way where I generated random numbers in the empty fields with an arbitrary max of 99 then I took the whole square passed it into a function that checks if it's a valid magic square.</p>
  <p>It basically keeps going forever till it finds the combination of numbers in the right places.</p>
  <p>Needless to say, this solution was dumb, it keeps going for hours before it finds the answer if ever.</p>
  <p>I also thought about doing an exhaustive number generation (basically trying every combination of numbers) till I find the right one but this faces the same issue.</p>
  <p>So I need help figuring out an algorithm or some way to limit the range of random number generated</p>