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);
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2021 年 5 月 16 日
This looks like a copy-paste of a Cody question (#114).This account is fairly new as well. Seems suspicious.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSudoku についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by