Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: filling area by color atack safety Date: Wed, 20 Mar 2024 09:29:54 +0100 Organization: A noiseless patient Spider Lines: 54 Message-ID: References: <87wmq2jn7s.fsf@bsb.me.uk> <86ttl3oo5b.fsf@linuxsc.com> <20240318142351.00001849@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 20 Mar 2024 08:29:54 -0000 (UTC) Injection-Info: dont-email.me; posting-host="94379038414d7c31b4109ba745631ea4"; logging-data="1474890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uJvvH5BvR/EL/yM2d2RM8J8iif5ws59o=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:9OplIZl8V7UmmPEU9eCXYIdu7H8= In-Reply-To: Content-Language: en-GB Bytes: 4007 On 19/03/2024 18:16, bart wrote: > On 19/03/2024 15:05, fir wrote: >> if this is 100x 100 square and i put the initioation >> in middle it would go 50x right then at depth 50 >> it would go one up than i guess 100 times left >> >> then just about this line up until up edge of picture >> - then it probably revert back (with a lot >> of false is) to first line and then go down > > That's what I thought until I tried it. > > If I start with an 18x18 image of all zeros, then fill starting from the > centre with a 'colour' that is an incrementing value, then the final > image displayed as a table of integers looks like this: > > > 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 > 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 > 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 > 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 >  99  98  97  96  95  94  93  92  91  90  89  88  87  86  85  84  83  82 >  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81 >  63  62  61  60  59  58  57  56  55  54  53  52  51  50  49  48  47  46 >  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45 >  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10 > 172 173 174 175 176 177 178 179 180   1   2   3   4   5   6   7   8   9 > 209 210 211 212 213 214 215 216 181 182 183 184 185 186 187 188 189 190 > 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 > 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 > 252 251 250 249 248 247 246 245 244 243 242 241 240 239 238 237 236 235 > 253 254 255 325 257 258 259 260 261 262 263 264 265 266 267 268 269 270 > 288 287 286 285 284 283 282 281 280 279 278 277 276 275 274 273 272 271 > 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 > 324 323 322 321 320 319 318 317 316 315 314 313 312 311 310 309 308 307 > > By following the sequence starting from 1, you can see the fill-pattern. > > It's not clear how it gets from 171 at top left to 172 half-way down the > left edge. > After the sequence hits the end at 171, it backtracks down the numbers. 27 is the first it reaches where there is a zero square neighbour, so it goes down from there - and the next number in the sequence is 172. Then it is free to move to the right again (then down after moving right is blocked at 180). I think your posts here gives a very nice and clear way to view the working of the algorithm. Thanks for doing that.