The GCHQ Puzzle Book – Rules

On a whim, I bought myself “The GCHQ Puzzle Book”. This has a variety of puzzles, none of them trivial. I’m going to tackle as many as I can and have set myself the following rules:

  1. The answer pages are to be taped shut!
  2. I must use my own brain before applying any of the following rules
  3. I can read and refer to any other part of the book (including the sample answers, hints, tips and reference section)
  4. I can look up specific facts in Wikipedia (but not go “trawling” for information)
  5. I can use the various text processing commands available on Linux
  6. In particular, I can use the word list to be found in /usr/share/dict/british-english
  7. I can write programs but only using the bash command shell

To help with some of the word based puzzles I have built a script to search the word list in various useful ways. Below is the help text, and the full program can be found at

To date I have completed all but two of the 68 introductory puzzles, and fewer than ten of the main ones, although I’ve made some progress with 20 or 30 others… I will report back on progress in a few months time.

Usage: word [flags] command string…

Commands are:

starts – show all words starting with string

ends – show all words ending with string

contains – show all words that have string embedded

anagram – show all (partial) anagrams of string

surround – show all words that start with string1 and end with string2 (*)

prefix – show the remaining part of all words starting with string (*)

suffix – show the remaining part of all words ending with string (*)

search – treat string as an arbitrary regular expression

(all commands may be abbreviated to their shortest unique length)

Flags are:

-w – ensure that output of the commands marked (*) are actually words

-1 – output results in a single column

-p – don’t include proper nouns in the results