Skip to content

Locksmith

Spectrum · BASIC

Combine clues to crack a hidden four-digit code

9 units

Start with Make room for a guess Browse lessons
Locksmith course capture
Locksmith · Spectrum

Four places, six possible digits and ten guesses. Crack the hidden code by combining what each clue tells you with the evidence already on the board.

Enter digits 1–6, then press Enter to submit four of them. D or Spectrum DELETE erases the last digit. EXACT counts right digits in right places; OTHER counts right digits elsewhere. Digits may repeat, but each occurrence counts only once. The clues report totals, without identifying individual matching digits.

An opened Locksmith round with its guesses, exact and other counts, and the revealed four-digit code.
The history keeps earlier clues available while you work out the next guess.

Locksmith runs in Sinclair BASIC on a stock 48K ZX Spectrum. It is silent and has no time limit. S starts from the title, R starts a new random round and Q quits. The answer stays fixed throughout a round and is revealed when the lock opens or ten unsuccessful guesses have been used.

From four spaces to a deduction

Begin a new program with an empty board. Build an editable guess, compare positions and handle repeated digits with occurrence counts. A visible practice code makes each step checkable before we hide the answer.

Keeping earlier guesses turns isolated clues into a deduction. We work through one example, then add random codes, endings, opening instructions and a self-starting tape. Nine lessons use seven runnable programs; the deduction and saving lessons reuse programs already built.