How to verify if a row or a column or a cubic 3x3 have a repeated number for sudoku?

조회 수: 1 (최근 30일)
NSHh
NSHh 2021년 5월 16일
댓글: NSHh 2021년 5월 17일
Say i got an 9x9 array and want to write a function to check if any row or column or 3x3 cell have a repeat number or not for sudoku. it would return a bolean value depend on the result. Any suggestion? Thank

답변 (1개)

Walter Roberson
Walter Roberson 2021년 5월 16일
Suppose you store NaN for all slots that have not had anything written to them. Then extract the appropriate portion of the array, such as
s = A(4:6, 1:3);
s(isnan(s)) = [];
had_dup = numel(unique(s)) ~= numel(s);

카테고리

Help CenterFile Exchange에서 Sudoku에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by