Cody

Problem 47478. Slitherlink V: Assert/Evolve/Check (large)

Solution 3640718

Submitted on 12 Nov 2020 by Richard Zapor
  • Size: 12894
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
s = 4; [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end assert(isequal(valid*pvalid,1))

sv trivial solution 1 2 4 3 1 sv = 1 2 4 3 1

2   Pass
%Source: Games World of Puzzles October 2020 s=[3 3 2 3 5 5 3 3 5 1; 5 5 5 2 5 5 5 5 5 5; 1 5 5 5 5 1 1 5 5 2; 0 5 5 5 5 2 5 5 3 3; 0 5 5 5 1 3 5 5 5 5; 5 5 5 5 2 3 5 5 5 0; 3 2 5 5 1 5 5 5 5 2; 3 5 5 2 0 5 5 5 5 2; 5 5 5 5 5 5 2 5 5 5; 3 5 1 3 5 5 3 3 2 3]; % solves with recursive [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end assert(isequal(valid*pvalid,1))

sv Assert solution 1 2 3 14 25 26 27 28 39 50 51 52 41 30 29 18 7 8 19 20 9 10 11 22 21 32 31 42 53 54 43 44 55 66 77 76 87 88 99 98 97 108 109 110 121 120 119 118 107 106 95 94 93 92 103 104 115 114 113 102 101 100 89 90 79 78 67 68 57 58 47 48 59 70 81 82 83 84 85 86 75 74 73 62 61 72 71 60 49 38 37 36 35 46 45 34 23 24 13 12 1 sv recursive solution 1 2 3 14 25 26 27 28 39 50 51 52 41 30 29 18 7 8 19 20 9 10 11 22 21 32 31 42 53 54 43 44 55 66 77 76 87 88 99 98 97 108 109 110 121 120 119 118 107 106 95 94 93 92 103 104 115 114 113 102 101 100 89 90 79 78 67 68 57 58 47 48 59 70 81 82 83 84 85 86 75 74 73 62 61 72 71 60 49 38 37 36 35 46 45 34 23 24 13 12 1 sv = Columns 1 through 29 1 2 3 14 25 26 27 28 39 50 51 52 41 30 29 18 7 8 19 20 9 10 11 22 21 32 31 42 53 Columns 30 through 58 54 43 44 55 66 77 76 87 88 99 98 97 108 109 110 121 120 119 118 107 106 95 94 93 92 103 104 115 114 Columns 59 through 87 113 102 101 100 89 90 79 78 67 68 57 58 47 48 59 70 81 82 83 84 85 86 75 74 73 62 61 72 71 Columns 88 through 101 60 49 38 37 36 35 46 45 34 23 24 13 12 1

3   Pass
%Source: Games World of Puzzles October 2020 s=['053552235013'; '505555535555'; '355135525552'; '521552155535'; '555305555553'; '535555335551'; '525050255352'; '325255555505'; '525555552521'; '152552253525'; '255533555535'; '255555522555'; '535551355315'; '355535512553'; '555525555515'; '132523255153']-'0'; % Solves with Assert [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end assert(isequal(valid*pvalid,1))

sv Assert solution 3 4 5 6 7 8 9 26 25 42 59 60 43 44 27 28 29 12 13 14 15 32 31 30 47 48 65 64 63 46 45 62 61 78 77 76 93 94 95 112 113 114 97 96 79 80 81 82 99 100 83 66 49 50 33 34 51 68 67 84 101 102 119 118 135 134 133 116 115 132 131 130 129 128 111 110 127 144 145 162 179 180 197 198 199 182 181 164 163 146 147 148 149 166 183 184 167 168 151 152 169 186 203 204 221 220 219 202 201 218 217 216 215 214 213 212 195 194 177 178 161 160 143 142 125 126 109 108 91 92 75 74 57 56 73 72 71 88 89 90 107 124 141 158 159 176 193 210 209 192 175 174 191 208 207 206 205 188 189 190 173 156 157 140 139 122 121 138 137 120 103 104 87 70 69 52 35 36 53 54 37 38 39 40 41 24 23 22 21 20 3 sv recursive solution 3 4 5 6 7 8 9 26 25 42 59 60 43 44 27 28 29 12 13 14 15 32 31 30 47 48 65 64 63 46 45 62 61 78 77 76 93 94 95 112 113 114 97 96 79 80 81 82 99 100 83 66 49 50 33 34 51 68 67 84 101 102 119 118 135 134 133 116 115 132 131 130 129 128 111 110 127 144 145 162 179 180 197 198 199 182 181 164 163 146 147 148 149 166 183 184 167 168 151 152 169 186 203 204 221 220 219 202 201 218 217 216 215 214 213 212 195 194 177 178 161 160 143 142 125 126 109 108 91 92 75 74 57 56 73 72 71 88 89 90 107 124 141 158 159 176 193 210 209 192 175 174 191 208 207 206 205 188 189 190 173 156 157 140 139 122 121 138 137 120 103 104 87 70 69 52 35 36 53 54 37 38 39 40 41 24 23 22 21 20 3 sv = Columns 1 through 29 3 4 5 6 7 8 9 26 25 42 59 60 43 44 27 28 29 12 13 14 15 32 31 30 47 48 65 64 63 Columns 30 through 58 46 45 62 61 78 77 76 93 94 95 112 113 114 97 96 79 80 81 82 99 100 83 66 49 50 33 34 51 68 Columns 59 through 87 67 84 101 102 119 118 135 134 133 116 115 132 131 130 129 128 111 110 127 144 145 162 179 180 197 198 199 182 181 Columns 88 through 116 164 163 146 147 148 149 166 183 184 167 168 151 152 169 186 203 204 221 220 219 202 201 218 217 216 215 214 213 212 Columns 117 through 145 195 194 177 178 161 160 143 142 125 126 109 108 91 92 75 74 57 56 73 72 71 88 89 90 107 124 141 158 159 Columns 146 through 174 176 193 210 209 192 175 174 191 208 207 206 205 188 189 190 173 156 157 140 139 122 121 138 137 120 103 104 87 70 Columns 175 through 191 69 52 35 36 53 54 37 38 39 40 41 24 23 22 21 20 3

4   Pass
s=['3553'; '1551'; '2112']-'0'; % evolves [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end assert(isequal(valid*pvalid,1))

sv evolve solution 1 2 3 4 8 12 16 20 19 18 17 13 14 10 6 5 1 sv = 1 2 3 4 8 12 16 20 19 18 17 13 14 10 6 5 1

5   Pass
s=['3212'; '1521'; '0532'; '1322']-'0'; % evolves [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end assert(isequal(valid*pvalid,1))

sv evolve solution 1 2 7 12 13 18 19 14 9 10 15 20 25 24 23 22 21 16 11 6 1 sv = 1 2 7 12 13 18 19 14 9 10 15 20 25 24 23 22 21 16 11 6 1

6   Pass
%Source: Games World of Puzzles October 2020 s=['225355223525'; '555235535535'; '555255555555'; '232535355512'; '355555535515'; '255035555502'; '555555522555'; '055515555315'; '513555535550'; '555025555555'; '015555522552'; '505535555553'; '315553525223'; '555555553555'; '525515531555'; '535312551533']-'0'; % solves with Assert, Dies in Recursion [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end assert(isequal(valid*pvalid,1))

sv Assert solution 1 2 3 4 21 38 39 22 5 6 23 24 41 40 57 56 55 72 89 90 73 74 91 92 75 76 59 42 43 60 61 44 27 28 45 62 63 64 65 48 49 32 31 30 13 14 15 16 17 34 33 50 51 68 85 84 67 66 83 82 81 80 97 98 115 116 99 100 101 118 119 136 153 170 187 186 203 204 221 220 219 218 201 200 217 216 199 198 181 164 165 166 183 184 185 168 167 150 151 152 135 134 133 132 149 148 147 130 113 96 95 78 77 94 111 110 127 126 109 108 107 106 123 124 125 142 141 158 159 160 143 144 145 128 129 146 163 180 179 162 161 178 195 212 211 210 193 192 209 208 207 206 205 188 189 172 173 190 191 174 157 156 155 154 137 138 139 122 121 120 103 86 69 52 53 70 87 88 71 54 37 36 35 18 1 sv recursive solution 1 2 3 4 21 38 39 22 5 6 23 24 41 40 57 56 55 72 89 90 73 74 91 92 75 76 59 42 43 60 61 44 27 28 45 62 63 64 65 48 49 32 31 30 13 14 15 16 17 34 33 50 51 68 85 84 67 66 83 82 81 80 97 98 115 116 99 100 101 118 119 136 153 170 187 186 203 204 221 220 219 218 201 200 217 216 199 198 181 164 165 166 183 184 185 168 167 150 151 152 135 134 133 132 149 148 147 130 113 96 95 78 77 94 111 110 127 126 109 108 107 106 123 124 125 142 141 158 159 160 143 144 145 128 129 146 163 180 179 162 161 178 195 212 211 210 193 192 209 208 207 206 205 188 189 172 173 190 191 174 157 156 155 154 137 138 139 122 121 120 103 86 69 52 53 70 87 88 71 54 37 36 35 18 1 sv = Columns 1 through 29 1 2 3 4 21 38 39 22 5 6 23 24 41 40 57 56 55 72 89 90 73 74 91 92 75 76 59 42 43 Columns 30 through 58 60 61 44 27 28 45 62 63 64 65 48 49 32 31 30 13 14 15 16 17 34 33 50 51 68 85 84 67 66 Columns 59 through 87 83 82 81 80 97 98 115 116 99 100 101 118 119 136 153 170 187 186 203 204 221 220 219 218 201 200 217 216 199 Columns 88 through 116 198 181 164 165 166 183 184 185 168 167 150 151 152 135 134 133 132 149 148 147 130 113 96 95 78 77 94 111 110 Columns 117 through 145 127 126 109 108 107 106 123 124 125 142 141 158 159 160 143 144 145 128 129 146 163 180 179 162 161 178 195 212 211 Columns 146 through 174 210 193 192 209 208 207 206 205 188 189 172 173 190 191 174 157 156 155 154 137 138 139 122 121 120 103 86 69 52 Columns 175 through 185 53 70 87 88 71 54 37 36 35 18 1

7   Pass
%Source: Games World of Puzzles October 2020 s=[5 1 5 5 3 5 5 5 0 1; 5 0 5 5 5 3 3 5 5 5; 5 5 5 1 2 5 5 5 3 5; 2 5 5 5 5 5 2 0 5 2; 0 5 5 5 5 5 5 5 5 5; 5 5 5 5 5 5 5 5 5 3; 3 5 1 2 5 5 5 5 5 1; 5 3 5 5 5 3 0 5 5 5; 5 5 5 0 0 5 5 5 3 5; 2 1 5 5 5 1 5 5 3 5]; % solves with recursive/assert [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end assert(isequal(valid*pvalid,1))

sv Assert solution 1 2 3 4 15 16 27 28 39 50 51 52 41 30 31 20 19 18 7 8 9 10 11 22 33 44 55 66 77 88 87 76 75 64 63 74 73 84 85 96 97 108 109 98 99 110 121 120 119 118 117 116 105 106 95 94 93 104 115 114 113 112 101 102 103 92 91 80 79 68 69 58 57 56 45 46 47 48 59 70 71 82 83 72 61 60 49 38 37 26 25 36 35 34 23 12 1 sv recursive solution 1 2 3 4 15 16 27 28 39 50 51 52 41 30 31 20 19 18 7 8 9 10 11 22 33 44 55 66 77 88 87 76 75 64 63 74 73 84 85 96 97 108 109 98 99 110 121 120 119 118 117 116 105 106 95 94 93 104 115 114 113 112 101 102 103 92 91 80 79 68 69 58 57 56 45 46 47 48 59 70 71 82 83 72 61 60 49 38 37 26 25 36 35 34 23 12 1 sv = Columns 1 through 29 1 2 3 4 15 16 27 28 39 50 51 52 41 30 31 20 19 18 7 8 9 10 11 22 33 44 55 66 77 Columns 30 through 58 88 87 76 75 64 63 74 73 84 85 96 97 108 109 98 99 110 121 120 119 118 117 116 105 106 95 94 93 104 Columns 59 through 87 115 114 113 112 101 102 103 92 91 80 79 68 69 58 57 56 45 46 47 48 59 70 71 82 83 72 61 60 49 Columns 88 through 97 38 37 26 25 36 35 34 23 12 1

8   Pass
% anti-hack case s=zeros(randi(4,1,2)+2)+5; s(randi(prod(size(s)))) = 4; [nr,nc]=size(s); nr1=nr+1; nc1=nc+1; p=zeros(nr1*nc1); bsegs=zeros(nr*nc,8); % borders c=reshape(1:nr1*nc1,nr1,nc1); % corners [er,ec]=find(c); emap=[er-1,ec-1]; % used by visualizer for i=1:nr for j=1:nc ptr=i+nr*(j-1); bsegs(ptr,:)=[c(i,j) c(i+1,j) c(i,j) c(i,j+1) c(i+1,j) c(i+1,j+1) c(i,j+1) c(i+1,j+1)]; end end %i for i=1:nr*nc for j=1:2:7 p(bsegs(i,j),bsegs(i,j+1))=1; end end [pr,pc]=find(p==1); pmap=[pr,pc]; %used by visualizer p=p+p'; sv=slitherlink(s,c,p,bsegs,emap,pmap) schk=s(:)*0; vsegs=sort([sv(1:end-1);sv(2:end)]',2); % make low to hi to match bsegs pairs idxvsegs=vsegs*[bsegs(end);1]; %Create an index value for easier comparison pvalid=1; %check path is valid, contiguous for i=1:length(sv)-1 pvalid=pvalid*p(sv(i),sv(i+1)); end for i=1:length(s(:)) % Create schk by examining all segments for each s index for j=1:2:7 % besgs pairs loop if nnz(idxvsegs==(bsegs(i,j)*bsegs(end)+bsegs(i,j+1))) schk(i)=schk(i)+1; end end end schk(s(:)==5)=5; % overwrite real values with unknown setting if isequal(schk,s(:)) valid=1; else valid=0; end assert(isequal(valid*pvalid,1))

sv trivial solution 17 18 24 23 17 sv = 17 18 24 23 17

Suggested Problems

More from this Author246

Community Treasure Hunt

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

Start Hunting!