You have entered a dungeon. You stand at the bottom of the staircase where you entered, facing east. A gnomish cartographer, carrying a bundle of scrolls, peers at you from nearby. As he moves to the staircase, he thrusts a scroll into your hands. Before you can respond, he has already left the dungeon.
Unrolling the scroll, you identify it as a magic map. It ripples and shifts into a symbolic representation of the dungeon:
[][[[[]][[[[][[]][[[[[[[][[[][][[]][[]]]]][[[]]]]][[]]]]][][[[]]]]]][[[][[[]]][[
[[][......[[...[[.[]][[[]][].[.......][...............].............]][[[[][]][]
[][]....]..]......[]][[[[][][...][.]...]............]...............][[[[][][[[]
[][[.....]....]]...........[..[][...[..[............[[[.............]]]][][][][]
]][[.][[]][][][]]][[][][]]...]..].....[.............]][[]]][][[.[[[[[]]]]]]]]]][
]][[.]][[]]]][]]]]][[]][]][[]][][[[].[[[]][[]][]]]][][[][[]][[].][[]][[]][[[[]]]
[][]............]][]]]][[][[][[[[]]]........]][]]]][][[][][]][[.........[]]]]]]]
[][][[][[]][][].]]]][[][][[]][[[]][]][]]]][.[[[[[][[]][[[[[][[[[][][]][.[]][[[[]
[[.................].....][]][[[]][]]][[[]].]][[[][[[...........][[....[.....[[]
[[.............<.]....][.]]]]...............[.[....[].[][]]]][]...[....].[...[][
[[.................[....[..[[..............[.....[....[[]]][]].[....[.....[..]][
[[..............[......[.[..............]....]..[..[[]][[]][][.].]..]....[...]][
][[][]][[[][[[[][][].]]][]][[][[][]][]][.[[[][[][[][[[[][[]][[][]]]][[].][[]][[[
[[[][][][............]][]][]]]][[]]]]][[.......[]]][[]]][[[[]]][[[......[]][][[[
[]][[][][.]]]]][]]]]]]][]]][[[]]][[[[[][[]]][].][[][][[]][][[]][][.][[][[[[[[[][
[].....[....]...].][[]]][[.....].....]...]...]...[....]]........]]......[...[[[]
][....[..]][..[............[]..]......]....[..]][.[.[.].]..][....]..].]..[..[]]]
[]......]]...[.....]][[]][[[]]...[..[...[.....[...[.[...[.]...[[..]....]....[[[]
][..........[..[...[]][[[[][]...[..[...[....[...[...[[[......[..[....[....[.[]][
]]][]][[]]]]][[[[][]][][]]]][[][]]][[]][]][[[[[[[[]]][][[]]]][[][[][[][[]][[[[[[
The dungeon is arranged as a grid of tiles. The directions on the map are right for east, down for south, left for west, and up for north. The staircase tile is marked < on the map.
You discover a contraption that was rolled into the map: an amulet of timekeeping. You sling it around your neck, resting close to your heart. With every tick of the clockwork, you are compelled to move forward to the next tile in your facing direction and trigger its effect. Triggering a lit or unlit floor tile (marked . or ) does nothing. All floor tiles in this dungeon are lit.
Besides the staircase and floor tiles, the dungeon also contains wall tiles: left-turners (marked [) and right-turners (marked ]). Wall tiles block you from moving forward to them, but you still trigger their effect. For a left-turner tile, turn 90 degrees to the left. For a right-turner tile, turn 90 degrees to the right.
As demonstrated by the gnome, you leave the dungeon by triggering the staircase tile. After how many ticks do you leave the dungeon?
From here, you can continue to the answer.
Consider an example dungeon:
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
The log below shows you exploring the example dungeon, with your location marked @ on the map. The status line uses the labels Dx for direction, Co for coordinates, and Tk for ticks. Coordinates are written as (x, y), where x increases to the east and y to the south. The origin is in the northwest corner, at the first tile on the map.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......@]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (8, 2) Tk: 0
---
A wall blocks your way east. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......@]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (8, 2) Tk: 1
---
You go south.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[..@.......[[][
[][]]][[][][[[]][]]]
Dx: South Co: (8, 3) Tk: 2
---
A wall blocks your way south. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[..@.......[[][
[][]]][[][][[[]][]]]
Dx: West Co: (8, 3) Tk: 3
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.@........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (7, 3) Tk: 4
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[@.........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (6, 3) Tk: 5
---
A wall blocks your way west. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[@.........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (6, 3) Tk: 6
---
A wall blocks your way south. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[@.........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (6, 3) Tk: 7
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.@........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (7, 3) Tk: 8
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[..@.......[[][
[][]]][[][][[[]][]]]
Dx: East Co: (8, 3) Tk: 9
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[...@......[[][
[][]]][[][][[[]][]]]
Dx: East Co: (9, 3) Tk: 10
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[....@.....[[][
[][]]][[][][[[]][]]]
Dx: East Co: (10, 3) Tk: 11
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.....@....[[][
[][]]][[][][[[]][]]]
Dx: East Co: (11, 3) Tk: 12
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[......@...[[][
[][]]][[][][[[]][]]]
Dx: East Co: (12, 3) Tk: 13
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.......@..[[][
[][]]][[][][[[]][]]]
Dx: East Co: (13, 3) Tk: 14
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[........@.[[][
[][]]][[][][[[]][]]]
Dx: East Co: (14, 3) Tk: 15
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.........@[[][
[][]]][[][][[[]][]]]
Dx: East Co: (15, 3) Tk: 16
---
A wall blocks your way east. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]..[.........@[[][
[][]]][[][][[[]][]]]
Dx: North Co: (15, 3) Tk: 17
---
You go north.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]..@...[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (15, 2) Tk: 18
---
A wall blocks your way north. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]..@...[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (15, 2) Tk: 19
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]...@..[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (16, 2) Tk: 20
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]....@.[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (17, 2) Tk: 21
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][].....@[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (18, 2) Tk: 22
---
A wall blocks your way east. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][].....@[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (18, 2) Tk: 23
---
You go north.
][[[]][]][[]][[][]][
[]][..........]]][@]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (18, 1) Tk: 24
---
A wall blocks your way north. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][@]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (18, 1) Tk: 25
---
A wall blocks your way east. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][@]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (18, 1) Tk: 26
---
You go south.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][].....@[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (18, 2) Tk: 27
---
A wall blocks your way south. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][].....@[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (18, 2) Tk: 28
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]....@.[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (17, 2) Tk: 29
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]...@..[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (16, 2) Tk: 30
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]..@...[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (15, 2) Tk: 31
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][].@....[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (14, 2) Tk: 32
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]@.....[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (13, 2) Tk: 33
---
A wall blocks your way west. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]@.....[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (13, 2) Tk: 34
---
You go north.
][[[]][]][[]][[][]][
[]][.........@]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (13, 1) Tk: 35
---
A wall blocks your way north. You turn left.
][[[]][]][[]][[][]][
[]][.........@]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (13, 1) Tk: 36
---
You go west.
][[[]][]][[]][[][]][
[]][........@.]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (12, 1) Tk: 37
---
You go west.
][[[]][]][[]][[][]][
[]][.......@..]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (11, 1) Tk: 38
---
You go west.
][[[]][]][[]][[][]][
[]][......@...]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (10, 1) Tk: 39
---
You go west.
][[[]][]][[]][[][]][
[]][.....@....]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (9, 1) Tk: 40
---
You go west.
][[[]][]][[]][[][]][
[]][....@.....]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (8, 1) Tk: 41
---
You go west.
][[[]][]][[]][[][]][
[]][...@......]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (7, 1) Tk: 42
---
You go west.
][[[]][]][[]][[][]][
[]][..@.......]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (6, 1) Tk: 43
---
You go west.
][[[]][]][[]][[][]][
[]][.@........]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (5, 1) Tk: 44
---
You go west.
][[[]][]][[]][[][]][
[]][@.........]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (4, 1) Tk: 45
---
A wall blocks your way west. You turn left.
][[[]][]][[]][[][]][
[]][@.........]]][.]
[.......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (4, 1) Tk: 46
---
You go south.
][[[]][]][[]][[][]][
[]][..........]]][.]
[...@...<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (4, 2) Tk: 47
---
You go south.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].].@[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (4, 3) Tk: 48
---
A wall blocks your way south. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].].@[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (4, 3) Tk: 49
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]@.[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (3, 3) Tk: 50
---
A wall blocks your way west. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
].]@.[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (3, 3) Tk: 51
---
You go north.
][[[]][]][[]][[][]][
[]][..........]]][.]
[..@....<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (3, 2) Tk: 52
---
A wall blocks your way north. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[..@....<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (3, 2) Tk: 53
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.@.....<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (2, 2) Tk: 54
---
You go west.
][[[]][]][[]][[][]][
[]][..........]]][.]
[@......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (1, 2) Tk: 55
---
A wall blocks your way west. You turn left.
][[[]][]][[]][[][]][
[]][..........]]][.]
[@......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (1, 2) Tk: 56
---
You go south.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
]@]..[..........[[][
[][]]][[][][[[]][]]]
Dx: South Co: (1, 3) Tk: 57
---
A wall blocks your way south. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
]@]..[..........[[][
[][]]][[][][[[]][]]]
Dx: West Co: (1, 3) Tk: 58
---
A wall blocks your way west. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.......<]][]......[
]@]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (1, 3) Tk: 59
---
You go north.
][[[]][]][[]][[][]][
[]][..........]]][.]
[@......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: North Co: (1, 2) Tk: 60
---
A wall blocks your way north. You turn right.
][[[]][]][[]][[][]][
[]][..........]]][.]
[@......<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (1, 2) Tk: 61
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.@.....<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (2, 2) Tk: 62
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[..@....<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (3, 2) Tk: 63
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[...@...<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (4, 2) Tk: 64
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[....@..<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (5, 2) Tk: 65
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[.....@.<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (6, 2) Tk: 66
---
You go east.
][[[]][]][[]][[][]][
[]][..........]]][.]
[......@<]][]......[
].]..[..........[[][
[][]]][[][][[[]][]]]
Dx: East Co: (7, 2) Tk: 67
---
You go east. You go upstairs.
Dx: East Tk: 68
You leave the example dungeon after 68 ticks.