Cody

# Problem 46028. Paint it black!

Solution 2953783

Submitted on 16 Sep 2020 by Jeremy Perez
• Size: 138
• 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
filetext = fileread('floodfill.m'); assert(isempty(strfind(filetext, 'eval')), 'Eval forbidden.'); assert(isempty(strfind(filetext, 'regexp')), 'Regexp forbidden.'); assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.'); assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.');

2   Pass
p = [1, 1]; input_color = 9; tolerance = 0; I =[9 9 9 2 9; 9 9 9 2 9; 2 2 2 9 9; 9 9 9 9 9]; y_correct = [105 177 73 204 122 130 214 108 173 122 154 247 132 149 158 137 49 171 159 188 197 146 104 212 84 234 120 67 160 122 71 32 47 185 5 209 49 198 215 117 128 125 185 181 102 14 159 250 201 95 158 167 242 21 94 99 214 253 223 168 146 133 126 232]; J = floodfill(I, p, input_color, tolerance); assert(all(uint8(py.hashlib.sha512(mat2str(J)).digest()) == y_correct));

3   Pass
p = [115, 133]; input_color = 1; tolerance = 0; I=imread(fullfile(matlabroot,'toolbox','images','imdata','blobs.png')); y_correct = [135 217 59 179 157 208 161 95 218 159 210 244 62 237 115 179 200 252 175 39 230 197 55 36 8 79 77 168 253 109 230 204 158 114 20 231 91 63 169 114 57 73 121 96 51 204 92 136 34 220 205 158 222 148 80 205 117 32 220 80 220 62 195 26]; J = floodfill(I, p, input_color, tolerance); assert(all(uint8(py.hashlib.sha512(mat2str(J)).digest()) == y_correct));

4   Pass
p = [170, 70]; input_color = 1; tolerance = 0; I=imread(fullfile(matlabroot,'toolbox','images','imdata','blobs.png')); y_correct = [45 21 215 148 24 198 184 203 33 38 222 107 60 205 211 33 76 33 62 139 133 58 42 238 77 128 243 214 143 201 181 109 218 80 3 41 44 130 179 21 51 87 168 161 118 110 241 214 236 45 210 130 28 94 170 39 9 240 10 103 158 207 214 203]; J = floodfill(I, p, input_color, tolerance); assert(all(uint8(py.hashlib.sha512(mat2str(J)).digest()) == y_correct));

5   Pass
p = [1500, 1840]; input_color = 204; tolerance = 5; I=imread(fullfile(matlabroot,'toolbox','images','imdata','concordorthophoto.png')); y_correct = [180 96 232 179 100 190 0 55 194 91 49 45 220 214 233 3 164 217 254 197 27 26 207 107 116 80 153 76 121 137 231 21 236 37 200 112 254 5 121 70 181 182 106 13 39 235 188 82 140 107 118 11 163 102 78 97 230 36 252 46 165 126 85 17]; J = floodfill(I, p, input_color, tolerance); assert(all(uint8(py.hashlib.sha512(mat2str(J)).digest()) == y_correct));

6   Pass
p = [375, 635]; input_color = [202, 67, 37]; tolerance = 175; I=imread(fullfile(matlabroot,'toolbox','images','imdata','flamingos.jpg')); y_correct = [30 139 106 7 97 110 190 130 24 218 242 177 34 121 66 214 96 87 10 195 170 9 145 230 222 27 243 72 82 124 63 198 151 209 215 250 32 44 207 179 112 121 173 232 193 144 31 238 152 205 145 57 41 194 8 221 119 157 210 6 83 112 142 99]; J = floodfill(I, p, input_color, tolerance); assert(all(uint8(py.hashlib.sha512(mat2str(J(:))).digest()) == y_correct));

### Community Treasure Hunt

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

Start Hunting!