[Community Puzzle] Fractal Image Recognition

https://www.codingame.com/training/medium/fractal-image-recognition

Send your feedback or ask for help here!

Created by @CSGO_BOT,validated by @DaNinja,@Smelty and @KAbel.
If you have any issues, feel free to ping them.

The stub is faulty: It reads β€˜imageSize’ chars per line, but input contains twice as much because of the separating spaces.

I think the best would be to just read it cell by cell:
loop imageSize loopline imageSize pixel:int

1 Like

I don’t understand these instructions,

" To place a fractal to the north (β€œ3”) of pixel P , pixels β€œ9”, β€œ5”, β€œ3”, β€œ4”, β€œ2” around pixel P must be empty.
To place a fractal to the northeast (β€œ4”) of pixel P , pixels β€œ5”, β€œ3”, β€œ4”, β€œ2”, β€œ7” around pixel P must be empty." .

When I put the northeast(β€œ4”) of pixel P (for the first extremum (1, 6)) , the fractal in the north (β€œ3”) can’t be empty 'cause there will be near each other (north and northeast) of the extremum.

And in the place of the result example, why we hadn’t :

0 0 0 0 0 5 3 4 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 1 1 0 0 0
0 0 0 0 1 0 1 0 0 0
0 0 9 1 0 0 1 0 0 0
0 0 8 6 7 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 8 6 7 0 0

Because you also need to have

at least 5 consecutive empty (β€œ0”) spaces around it.

For example, the 5 you’ve placed at the top has only 4 consecutive empty spaces around the 1 pixel, so the 5 cannot be placed there.