Brainteasers: Safecracker

By Genevieve Ludinski

Originally published in EUG #52


This EUG begins a series of articles and utilities with a mathematical bias entitled Brainteasers; each program designed to puzzle and amuse its users. Brief instructions are given on screen before each puzzle begins while detailed documentation on the programs themselves can be viewed if you wish to try your hand at changing any elements of them.


You are really up against the clock on this one as you must solve as many puzzles as possible, in just 200 seconds. A series of numbers, or letters, will be positioned around five of the sides of a hexagon and you will be asked to provide the missing letter or number. The relationship between the numbers or letters may be with their corresponding number or letter on the opposite side of the hexagon, or it may follow in sequence from an adjacent number.

The decision is yours.

How To Play

Key in the number, or letter, of your choice and press RETURN.

Programming Hints

This program has a timer that displays the time in seconds on the screen while the computer is waiting for the player to key in something. This is a very useful facility and is done by setting the system variable TIME to zero at the start of the program. Time will then hold the time in seconds multiplied by 100. This can be displayed on occasions throughout the program but is more effective being displayed constantly, especially when the program is waiting for the player to key in something. This is done by using INKEY$(10) in a loop which keeps checking if a key has been pressed and, if it has not, it displays the time (see line 470). When a key has been found to be pressed, the program waits for the rest of the digits to be keyed and knows you have finished when the RETURN key is pressed, i.e. GET$=CHR$(13).

One change to make the puzzle easier, is to reduce the size of the numbers used. S(2) on line 150 is the value of the first number in the sequence if the pattern is a sequence of numbers going around the hexagon. IC on line 160 is related to the interval between the numbers going round the hexagon. So if the 9 in line 150 is changed to a smaller number and IC is always 1 this will make the puzzle easier.

If you wish to make the puzzle more difficult (and you must be brave or a genius to want to do so), then you could either increase the possible values of S(2) or IC or increase the number of different types of sequence. At present there are five types of sequences depending on whether W is 0 to 4. If you allow W to become 5 or larger in line 170, you could add a new sequence type for W=5 after line 230.


Are you a quick-thinker or a deep thinker? I hope you are one or the other, or you will never be able to crack open someone else's safe!

This game can be played two different ways, depending on whether you are a quick or a deep thinker. If you are not sure which you are, then I suggest you play it both ways, and find out which gives you the highest score.

In all cases, a closed safe is displayed and you are given two clues about the secret code that opens it. If you work out the exact answer before keying in the code, you are given two minutes to do it. If you make guesses, then you are only allowed sixteen seconds. Wrong answers are ignored.

If you take too long, you are surprised by the caretaker who switches on the light. He then presses the alarm button and you hear the police sirens wailing and you know all is lost.

If you do manage to crack the code in time, the safe opens revealing gold bullion.

How To Play

You are given two clues and the code is always a two digit number. Key in the number. You do not need to press RETURN.

To end the program, press E.

Programming Hints

This program contains two useful procedures: PROC_BLOCK draws a rectangle whose lower left hand corner is X,Y and whose width is W and height is H. PROC_PARLL draws a parallelogram with two sides vertical. Put the coordinates of the lower, left-hand corner in X1, Y1 and those of the upper right hand corner in X2, Y2.

If you want to make the game easier, you can increase the time allowed to guess or reduce the number of digits allowed in the code or both.

To increase the time allowed for guesses, increase the value of TM in line 240. To increase the time allowed when only one answer is keyed in, increase the value of TM in line 220.

To reduce the number of digits allowed, reduce the number inside the RND brackets for XX and YY in line 520.

If you find the game too easy then do the opposite.