Me and my wife occasionally play a simple game when on longer car journeys. In the UK the last 3 characters in a car registration plate are letters.
The aim of the game is to come up with words which start with the first
letter, end with the last letter and contain the middle letter. So for
the example plate in the image above we’d use SMR, a word that we could
choose would be ‘speedometer (since it starts with s, ends with r and
contains m’). Computers, unsurprisingly, are very good at this. Here’s
an example of a super simple python script which prints matching words
(this assumes you are on a Linux system, or at least a system with
/usr/share/dict/words
.
import sys
if len(sys.argv) < 2:
print "Please provide a reg plate"
exit()
reg_plate = sys.argv[1].lower()
words = open('/usr/share/dict/words','r')
print "Words for: "+reg_plate
for word in words:
word = word.strip()
if word[0] == reg_plate[-3] and word[-1] == reg_plate[-1] and reg_plate[-2] in word[1:-1]:
print word
It can be called using python reg_plate_game.py "BD51 SMR"
. This
example outputs the following:
salamander
samovar
sampler
scamper
scandalmonger
schemer
schmaltzier
schoolmaster
scimitar
scoutmaster
scrambler
scummier
seamier
seemlier
semester
semicircular
semiconductor
seminar
semitrailer
shimmer
shoemaker
similar
simmer
simper
simpler
simulator
skimpier
slammer
sledgehammer
slimier
slimmer
slumber
slummer
smacker
smaller
smarmier
smarter
smear
smellier
smelter
smoggier
smoker
smokier
smolder
smoother
smother
smoulder
smudgier
smugger
smuggler
smuttier
solemner
somber
spammer
speedometer
squirmier
stammer
stammerer
steamer
steamier
steamroller
stepmother
stormier
streamer
stumbler
stumpier
sublimer
submitter
summer
summerier
summoner
supercomputer
swampier
swimmer
sympathizer