Is this continuous terrain?Is this continuous terrain?
You're given a piece of ASCII art representing a piece of land, like so:
/‾\
__/ ‾\_
\_/‾\
\
Since an overline (‾
) is not ASCII, you can use a ~
or -
instead.
Your challenge is to determine if it is connected by the lines of the characters. For example, the above can be traced like so:
To clarify the connections:
_
can only connect on the bottom on either side‾
(or~
or-
) can only connect on the top on either side/
can only connect on the top right and bottom left\
can only connect on the top left and bottom right
It doesn't matter where the connections start and end as long as they go all the way across. Note that one line's bottom is the next line's top, so stuff like this is allowed:
_
‾
\
\
_
/
\
‾
You can assume input will only contain those characters plus spaces and newlines, and will only contain one non-space character per column.
Input can be taken as ASCII art, an array of rows, a character matrix, etc.
Testcases
Separated by double newline.
Truthy:
\
\
\_
\ /\/\_
‾ \
/\
\/
\_
‾\
/‾\
__/ ‾\_
\_/‾\
\
Falsy:
/
\
//
‾‾
/ \
‾
_
\____/
/‾‾‾\