I wrote this little program to help out with a puzzle presented in the December 1985 issue of the Mensa Bulletin. The puzzle almost cries out for computerized help, but even a computer will only help a little.
The puzzle probably has many thousands of solutions. Some solutions however, are better than others. No matter how well you do, you’ll be continually be drawn back in hope of a better answer. (” Sure, honey, I know it’s late. Just a few more minutes and I’ll have this thing licked.”)
The puzzle works by taking a word, shifting each letter a certain number of positions in the alphabet, and getting another word. For example, if you shift every letter forward one position ( A becomes B, B becomes C, C becomes D … Z becomes A) the word “ants” becomes “bout”. If we start with the word “lap”, and shift every letter four positions, we get “pet”, and if we instead shift every letter 15 positions, we get “ape”.
As a side bit of trivia, many readers are familiar with HAL, the mad computer in 2001: A Space Odessey. Not many readers know why the name HAL was chosen by the author. If every letter in that name is shifted one position, you’ll get another very well known name.
Oh well, back to reality. The object of this puzzle, then, is to find the longest word that can be shifted into another word. How many shift positions you use doesn’t matter.
The following program will help you in working through the puzzle. You simply type in a word and and you’ll see it, along with all 25 possible position shifted “words”. You need only scan down the list to see if there are other real words in there as well.
The program I’ve given is a deliberately simple version. This will allow you to understand and modify it to do whatever timesaving tricks you may think of. When you RUN it, it will simply expect you to type in a word ( CAPS SHIFTED only!!) and press ENTER. It will display all 26 letter combinations associated with the word you’ve typed in. These “words” will be displayed until you press any key, except the number keys.
The number keys are special. For example, if you press the “2” key, the second letter in each word will be shifted one position. Whether or not it’s obvious, this new list also represents a solution to the puzzle, if you can find two or more recognizable words in it. However, if your “words” contain 5 letters each, don’t press a number key higher than 5, or you’ll get garbage on the screen. (Remember, I said this program is a simple version.)
If this description seems complicated, just type in the program and try it; all should become clear.
I found that it was initially fun to try random words. But beware, the longer words rarely give a match. The next step was to try short words, or portions of words, and slowly expand them, if any combination shows promise. You’ll want to develop your own strategy, and modify the program to compliment it.
If you rewrite the program for another computer that has a spelling checker (which includes a fairly exhaustive list of words in the English language) you may be able to do a reasonably complete treatment of this puzzle. Unfortunately, I suspect that trying every word in the dictionary file, and comparing every “word” that results to the file also, will require a lot of patience.
Whatever you do, have fun, and let me know of the longest solution you find.
WORDSHIFT
10 REM BY WES BRIOZOWSKI 12/85
20 REM *****NOTE LINE 105****
THE POKE PUTS THE CURSOR INTO
CAPS MODE FOR YOU.
100 CLS
105 POKE 23658,8
110 INPUT "letters ";a$: LET len
gth=LEN a$
120 FOR j=0 TO 12
125 PRINT TAB 16;
130 GO SUB 300
140 NEXT j
150 PRINT AT 0,0;
160 FOR j=13 TO 25
180 GO SUB 300
190 NEXT j
200 PAUSE 0
210 LET a=CODE INKEY$: IF a<49
OR a>57 THEN GO TO 100
220 LET a=a-49: LET b$=SCREEN$
(0,16+a)
230 LET b=CODE b$: LET b=b+1
240 FOR j=0 TO 12: PRINT AT j,1
6+a;: IF b>90 THEN LET b=b-26
250 PRINT CHR$ b: LET b=b+1: NE
XT j
260 FOR j=0 TO 12: PRINT AT j,a
;: IF b>90 THEN LET b=b-26
270 PRINT CHR$ b: LET b=b+1: NE
XT j
290 GO TO 200
300 FOR k=1 TO length
310 LET c=j+CODE a$(k)
320 IF c>90 THEN LET c=c-26
330 PRINT CHR$ c;
340 NEXT k
350 PRINT
360 RETURN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.