2017-12-15

The Advent of Void: Day 15: an

Time for some fun! Surely you know what an anagram is: a rearrangement of the letters of a sentence to yield a different sentence. For example, ELVIS has the same letters as LIVES, and THE MORSE CODE has the same letters as HERE COMES DOTS.

How can we find such anagrams? With our computer! Today, we’ll use the tool an(6) for that.

By default, it will list all anagrams it finds, with the longest word first:

% an butterfly |head    
butterfly
fluttery b
fluttery B
utterly bf
utterly f b
utterly f B
utterly b F
utterly F B
flutter by
flutter Yb

We can limit the minimum word length with -m to filter out the single letters:

% an -m3 butterfly |head
butterfly
butter fly
belfry tut
belfry Tut
turfy belt
lefty Burt
lefty Brut
beryl tuft
Betty furl
Beryl tuft

When we are just looking for inspiration, -w will list all words that are contained in the sentence:

% an -w butterfly |head 
butterfly
fluttery
utterly
flutter
buttery
turtle
tufter
butter
butler
belfry

If we want to make a more complicated anagram, it also help if we can mark some letters as used, with -u:

% an -m3 -u Merriest 'Christmas Tree' 
chats
chat's
ACTH's

Ah, yes: CHRISTMAS TREE and MERRIEST CHATS.

Finally, an can also test if two sentences are anagrammatic:

% an -t 'Atomic Tests are fun idea' 'United States of America' 
Atomic Tests are fun idea can be made from United States of America

Finally, if you are looking for anagrams in other languages, you can pass a different dictionary with -d. Void Linux includes e.g. words-de.