Location: Variations: arrays, logs, queues, stacks, sets, sieves and rings
RecipeLocation: Bags, Bottles, Boxes and Safes
Index: Safe with a multi-number combination
Description: A safe with a multi-number combination, meant to be dialed over multiple turns, is implemented using a log of the last three numbers dialed. The log can then be compared to the safe's correct combination.
It is not difficult to implement a safe which can be set to a single number to open; but a more common scenario in the real world is for the safe to open on a sequence of numbers when they have been dialed in the right order.
For IF, this means that we have to keep running track of the last N digits the player has dialed, dropping the first digit and adding a new one to the end each time the player re-dials the safe. This is a perfect occasion for lists:
{*}"Eyes, Fingers, Toes"
The Addams Wine Cellar is a room. It contains a closed lockable locked container called a safe.
Test me with "x safe / set safe to 10 / x safe / set safe to 29 / x safe / set safe to 2 / x safe / set safe to 10 / x safe / set safe to 11 / open safe / set safe to 14 / close safe / set safe to 15 / open safe".