Skip to main content
posted question
Source Link
Joao-3
  • 1.4k
  • 2
  • 5

Walk by walls Walk by walls in a room

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/
X -> false (hits boundary)
X    |

       -> true


    \
X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!

Walk by walls

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/
X -> false (hits boundary)
X    |

       -> true


    \
X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!

clarified where tests start
Source Link
Joao-3
  • 1.4k
  • 2
  • 5

Walk by walls

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/
 
 
X -> false (hits boundary)
 
 
X    |

       -> true


    \
 
 
X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!

Walk by walls

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/
 
X -> false (hits boundary)
 
X    |

       -> true


    \
 
X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!

Walk by walls

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/
 
X -> false (hits boundary)
 
X    |

       -> true


    \
 
X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!

Source Link
Joao-3
  • 1.4k
  • 2
  • 5

Walk by walls

Challenge

You just entered a room. Here's how it looks (you are the X):

|\  /|
| \/ |
| X  |
|    |
|----|

You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then you follow the next appropriate direction in a clockwise cycle (for visualization purposes, you leave a trail behind in this visualization and the starting square is shown):

|\  /|
| \/ |
| Sxx|
|   X|
|----|

You continue following this pattern.

|\  /|
|X\/ |
|xSxx|
|xxxx|
|----|

And yes, you reached the starting point.

|\  /|
|x\/ |
|xXxx|
|xxxx|
|----|

However, if there was a hole, you could get lost:

|\  /|
| \/ |
| SxxX
|    |
|----|

Input

As input, in any reasonable format, your program must recieve the room you are in, which consists of walls (|/-\), spaces and your starting point (the X) (the starting direction is always right).

Output

As output, your program needs to output a truthy or falsy value representing if you got to your starting point.

Test cases

The format here is input -> output (reason for being false).

/-\
|X| -> true
\-/

X -> false (hits boundary)

X    |

       -> true


    \

X    |
 -
   |   -> false (trapped in endless loop)
|
  - -

Scoring

This is , so the program with the least bytes wins!