You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function [flag,ANSWER]=SolveSudoku(ANSWER,minimumarray,all_possible_elements)%minimumarray contains coordinates with lease possible candidates
2
+
%all_possible_elements has all empty coordinates and possible candidates size
3
+
flag2=0; %Flag2 to notify that a swap has been done in this function earlier
4
+
if CheckForEmptyBox(ANSWER)==0%if flag is 1 loop ends and answer is displayed
5
+
flag=1;
6
+
return
7
+
end
8
+
s3=size(minimumarray);
9
+
for i=1:s3(1)
10
+
if CheckForSUDOKUconsistency(ANSWER,all_possible_elements)==0%true
11
+
ifflag2==1
12
+
[minimumarray1,all_possible_elements1]=MoreAccurateSpace(ANSWER);%If it was already swapped from previous assigned value then no need to check for next coordinate
13
+
else
14
+
min_array=FindMinArray(minimumarray(i,1),minimumarray(i,2)); %Finds which smaller 3x3 array where element (x,y) belongs
15
+
elements=CollectElements(min_array,ANSWER); %extract that 3x3array
16
+
possible_elements=PossibleValues(elements,minimumarray(i,1),minimumarray(i,2),ANSWER);%finds XOR of all elements in row,column and 3x3 array with 1-9 characters
17
+
ANSWER(minimumarray(i,1),minimumarray(i,2))=possible_elements(1,1);%amend ANSWER array with possible element or supposed possible element
0 commit comments