Module day22

Source
Expand description

§Wizard Simulator 20XX

Dijkstra’s algorithm is ideal for solving this problem. A node in the graph is our current state and each edge is represented by casting a spell to get to a new state.

The key to optimizing is to cache previously seen states. As we receive states in strictly increasing order of mana spent if we see a state again then it cannot possibly be optimal and we can discard.

Structs§

State 🔒

Functions§

apply_spell_effects 🔒
Applies spell effects to state and returns true if the player has won.
boss_turn 🔒
Applies boss attack and returns true if the wizard survives.
parse
part1
part2
play 🔒

Type Aliases§

Input 🔒