Task
Given a ASCII diagram of a loop
e.g.
....................
......@@@@@.........
......@...@.........
.....@@...@@@@@.....
....@@........@.....
....@........@@.....
....@@@@@@@@@@......
....................
....................
And a location on the loop
e.g.
(7,1)
You must find the inside and outside of the loop
e.g.
00000000000000000000
00000011111000000000
00000011111000000000
00000111111111100000
00001111111111100000
00001111111111100000
00001111111111000000
00000000000000000000
00000000000000000000
Specifications
You may take input for the diagram as a string separated by newlines or obvious equivalent
You will receive a coordinate on the loop (0 or 1 indexed) as part of your input. You may place your origin at any place you wish. You may take this coordinate in
(<row>, <column>)
,(<column>, <row>)
or as the linear position on the string. You may receive these data in any reasonable method. All characters on the loop will be the same as the character at that index.Preferred output is a 2 dimensional array of truthy and falsy values, however strings of
1
and0
separated by newlines or any obvious equivalent of the later two are accepted. The inside and outside must have different truth values but it does not matter which is which.A loop is defined as a group of characters such that they are all the same character (e.g.
@
) and so that every character in the loop has a path to the original character (The character at the coordinate of input) that only passes through that same character (Taxicab geometry No diagonals).The inside is all the loop itself and the places that cannot reach the edge of the diagram without crossing the loop.
The outside is everywhere else
This is code-golf
[['.', '.'],['.', '@']]
instead of a string with newlines? \$\endgroup\$ – hbaderts Jan 17 '17 at 16:19