hi - I’m trying to build a sudoku generator. I’m trying to remove an element from a table with the following code:
for j = (currentSquare + 1),9 do for p=1,#sudoku[j] do if (sudoku[j][p] == numberChosen) then table.remove(sudoku[j],sudoku[j][p]) break end end
I am trying to remove the number “numberChosen” from the table.
What is going wrong here is that the element is being removed from position “numberChosen”, not from position [p]. So, for example, if I have the table
{1,3,4,6}
and “numberChosen” is 3, the value of p will be 2 but it removes the 4, i.e. not “numberChosen”, but the number at position “numberChosen”.
I am bewildered. What am i doing wrong?
thanks.
