• 109

## Goal

Goal of this puzzle is to found pirate's treasure.
Input
Line 1: Width W of treasure map.
Line 2: Height H of treasure map.
Next H lines: W symbols (0 or 1) indicating free space (0) or obstacle (1).

Treasure is placed on free space surrounded by only obstacles.

There are three possibilities how can be the treasure surrounded:
By 3 obstacles when the treasure is in the corner of the map.
By 5 obstacles when the treasure is on the edge of the map.
By 8 obstacles when the treasure is inside the map.
Output
Coordinates of treasure in map represented by indexes separated by space. For example: "12 5"

Position "0 0" is in the top left corner, so maximum index x is W-1 and maximum index y is H-1.
Constraints
* 2 <= W <= 25
* 2 <= H <= 25
* Only 1 treasure in map.
Example
Input
2
2
0 1
1 1
Output
0 0

A higher resolution is required to access the IDE

Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants