Caves and Cliffs edition
You're given a piece of ASCII art representing a piece of land, like so:
/‾\ _ __ __/ _/ \‾ _/ __/‾\ | / / ‾\ | \_/‾ \_/
But unlike in the previous challenge, the terrain is mountainous, with caves and cliffs, and can turn back on itself. Also, a new character is introduced,
|, which can connect to any of its four corners.
Since an overline (
‾) is not ASCII, you can use a
Your challenge is still to determine if it is connected by the lines of the characters such that a single line connects them all without backtracking or crossing itself. For example, the above can be traced like so:
To clarify the connections:
_can only connect on the bottom on either side
-) 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
|can connect on all four corners, but not to anything that connects to more than one corner.
|must have a single connection above itself and a single connection below.
That one's a bit confusing, so the following are legal:
| \ | \ _ |_ ‾| /
And the following aren't:
| ‾ _ | ||
It doesn't matter where the connections start and end as long as they're all connected. 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 contain at least one non-space character per column.
Input can be taken as ASCII art, an array of rows, a character matrix, etc.
Separated by double newline.
\ \ \_ \ /\/\_ ‾ \ /\ \/ \_ ‾\ /‾\ __/ ‾\_ \_/‾\ \ /‾\ _ __ __/ _/ \‾ _/ __/‾\ | / / ‾\ | \_/‾ \_/ /‾\ \ / / \ ____ _ ___| | | | ___| | | |___ | |___ | | ___| | | |_____| | _ / \ _ | |_| _ |_\
/ \ // ‾‾ / \ ‾ _ \____/ /‾‾‾\ \_ / | | ‾‾‾ |_| | |