Skip to main content
deleted 2456 characters in body
Source Link
emanresu A
  • 44.2k
  • 25
  • 40

Is this continuous terrain? Part II

Caves and Cliffs edition

Part 1

Very related

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 ~ or - instead.

Your challenge is still to determine if it is connected by the lines of the characters. For example, the above can be traced like so:

enter image description here

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
  • | 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.

TestcasesIs this continuous terrain? Part II

Separated by double newline.

Truthy:

\
 \

\_
  \ /\/\_
   ‾     \

/\
  \/

\_
  ‾\

   /‾\
__/   ‾\_
         \_/‾\
              \

   /‾\         _ __
__/ _/         \‾  
  _/  __/‾\     |  
 /   /     ‾\   |  
 \_/‾        \_/   

/‾\
\ /
/ \

____   _
 ___| | |
|  ___| |
| |___  |
|___  | |
 ___| | |
|_____| |

 _
/ \  _
| |_|

 _
|_\
  

Falsy:

/
 \


//

 ‾‾
/  \

‾
 _

\____/
      /‾‾‾\

\_
/

| |
‾‾‾

|_|
| |



Is this continuous terrain? Part II

Caves and Cliffs edition

Part 1

Very related

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 ~ or - instead.

Your challenge is still to determine if it is connected by the lines of the characters. For example, the above can be traced like so:

enter image description here

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
  • | 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.

Testcases

Separated by double newline.

Truthy:

\
 \

\_
  \ /\/\_
   ‾     \

/\
  \/

\_
  ‾\

   /‾\
__/   ‾\_
         \_/‾\
              \

   /‾\         _ __
__/ _/         \‾  
  _/  __/‾\     |  
 /   /     ‾\   |  
 \_/‾        \_/   

/‾\
\ /
/ \

____   _
 ___| | |
|  ___| |
| |___  |
|___  | |
 ___| | |
|_____| |

 _
/ \  _
| |_|

 _
|_\
  

Falsy:

/
 \


//

 ‾‾
/  \

‾
 _

\____/
      /‾‾‾\

\_
/

| |
‾‾‾

|_|
| |



Source Link
emanresu A
  • 44.2k
  • 25
  • 40

Is this continuous terrain? Part II

Caves and Cliffs edition

Part 1

Very related

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 ~ or - instead.

Your challenge is still to determine if it is connected by the lines of the characters. For example, the above can be traced like so:

enter image description here

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
  • | 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.

Testcases

Separated by double newline.

Truthy:

\
 \

\_
  \ /\/\_
   ‾     \

/\
  \/

\_
  ‾\

   /‾\
__/   ‾\_
         \_/‾\
              \

   /‾\         _ __
__/ _/         \‾  
  _/  __/‾\     |  
 /   /     ‾\   |  
 \_/‾        \_/   

/‾\
\ /
/ \

____   _
 ___| | |
|  ___| |
| |___  |
|___  | |
 ___| | |
|_____| |

 _
/ \  _
| |_|

 _
|_\
  

Falsy:

/
 \


//

 ‾‾
/  \

‾
 _

\____/
      /‾‾‾\

\_
/

| |
‾‾‾

|_|
| |