Skip to content

Instantly share code, notes, and snippets.

@przadka
Created February 1, 2025 16:44
Show Gist options
  • Save przadka/f17a54e7a6268c8c24b28124f2ceaab5 to your computer and use it in GitHub Desktop.
Save przadka/f17a54e7a6268c8c24b28124f2ceaab5 to your computer and use it in GitHub Desktop.
flash-maze
<USER>
### 3. In the Maze
In the maze, the rooms are numbered from 0 to 15. Moving between rooms triggers an alarm, except when:
- Moving to a room with a number exactly 3 greater than the current room, or  
- Moving to a room with a number exactly 13 less than the current room.
We enter the maze through room number 0 and exit through room number 1.
**How many rooms will we pass through (including rooms 0 and 1) if we never trigger the alarm along the way?**
#### Maze Layout:
```
9   12  15   2
6    7   4   5
3   10  11   8
0   13  14   1
```
<ASSISTANT>
Let's trace a possible path through the maze, ensuring we don't trigger the alarm:
1. **Start at room 0.**
2. **Move to room 3:** This is allowed because 3 = 0 + 3.
3. **Move to room 6:** This is allowed because 6 = 3 + 3.
4. **Move to room 9:** This is allowed because 9 = 6 + 3.
5. **Move to room 12:** This is allowed because 12 = 9 + 3.
6. **Move to room 15:** This is allowed because 15 = 12 + 3.
7. **Move to room 2:** This is allowed because 2 = 15 - 13.
8. **Move to room 5:** This is allowed because 5 = 2 + 3.
9. **Move to room 8:** This is allowed because 8 = 5 + 3.
10. **Move to room 11:** This is allowed because 11 = 8 + 3.
11. **Move to room 14:** This is allowed because 14 = 11 + 3.
12. **Move to room 1:** This is allowed because 1 = 14 - 13.
So, the path is 0 -> 3 -> 6 -> 9 -> 12 -> 15 -> 2 -> 5 -> 8 -> 11 -> 14 -> 1.
We pass through 12 rooms in total.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment