The Rune-Pools of Drussek Warren
The Cartographers' Lodge of Bitwick posts a bounty for the swiftest route through Drussek Warren. The warren is an abandoned kobold delve, and its tunnels are threaded with enchanted pools. Every pool is carved with a rune. Pools carved with the same rune are joined: a diver who plunges into one may surface in any other pool bearing that rune.
The warren's map is given as grid, a list of equal-length strings. Each character is one tile:
#is rock and cannot be entered..is open tunnel.Sis the entrance. There is exactly one.Eis the hoard chamber. There is exactly one.- A lowercase letter
a-zis a pool marked with that rune.
Each step is one of the following:
- A move to an orthogonally adjacent tile (up, down, left or right) that lies within the grid and is not
#. - If you are standing on a pool, a dive to any *other* pool tile with the same letter, anywhere in the grid.
Each move and each dive counts as one step. Pool tiles are also ordinary open tiles. You may walk onto and off them without diving, and diving is never forced. A rune that appears on only one tile offers no dive.
Write delveRoute(grid). It returns the minimum number of steps needed to get from S to E, as an integer. If E cannot be reached, it returns -1.
examples
- case 1
grid = ["Sa##aE"]3. Step onto the first pool, dive to the other `a` pool past the rock, then step into the hoard chamber. - case 2
grid = ["Sa#E"]-1. The rune `a` appears only once, so there is nowhere to dive, and the rock blocks the tunnel. - case 3
grid = ["SaE", "###", "..a"]2. Walk across the pool without diving: S, then a, then E. - case 4
grid = ["S#.....", "a#.###.", "##a#Ea."]3. Step down onto the pool, dive to the `a` pool beside the hoard chamber (not the one in the middle), then step left into E.
- reward
- 320 XP
- signature
delveRoute
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- single dive across rock
- plain walking maze with no pools
- hoard walled off
- lone rune offers no dive
- chain of two different runes
- three pools share a rune
- diving is optional
- dive beats a long walk
- entrance beside the hoard
- two chambers joined by one rune