1 view (last 30 days)

I struggling with an assignemt in which i have to find the remaining number in a single sudoku row. I have to replace 0 with a number which doesnt match the current numbers i the row.

my current is:

function sudokuRow = fillSudokuRow(sudokuRow)

sudokuRow(sudokuRow==0)=a;

I can make it replace the 0 with a secpific number but i cant figure out how to make variate numbers depending on the numbers in the suduko row?

Matt J
on 16 Feb 2020

Edited: Matt J
on 16 Feb 2020

function sudokuRow = fillSudokuRow(sudokuRow)

idx=(sudokuRow==0);

sudokuRow(idx)=func(sudokuRow(~idx));

end

Matt J
on 16 Feb 2020

These pages talk about the syntax for composing functions

Matt J
on 16 Feb 2020

@Joakim,

To be a bit clearer, your question asks about how to extract the non-zeros and do "something" with them, and that's what my answer demonstrates how to do, in the same generality in which your question is phrased. But your post does not say that you see a difficulty even after you have the non-zeros, nor what that difficulty is.

You also seem to think that we can offer more help with no explanation about what func() is required to do. But I don't know why we should know what comes next better than you. Would it be clear to someone familiar with Sudoku? I myself have never played....

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.