Move a few letters and one idea becomes another: LOGARITHM turns into ALGORITHM. Beyond the pleasant coincidence lies a meeting point between language, mathematics, computing and creativity.

We begin with a simple question: what must stay unchanged when letters move? That question leads to counting possibilities, choosing an efficient algorithm and discovering why a clever sentence is not necessarily a correct anagram.
LOGARITHM ⇄ ALGORITHM
1. Letters change places, not identities
An anagram rearranges every letter in a word or phrase without adding or removing any. Having the same kinds of letters is not sufficient: their frequencies must also match. Mathematically this is a multiset, a collection in which repetitions matter.
Here we ignore spaces, apostrophes, punctuation and differences in letter case. We keep accents and letters such as ñ rather than deleting them to rescue an example. In a digital check, Unicode NFC normalization prevents equivalent encodings of an accented letter from being mistaken for different characters.
Letter accuracy is an objective constraint. Meaning, humour and fluency form another layer: a good literary anagram must pass both tests.
Unicode normalization: technical reference
2. When words tell a story
LISTEN becomes SILENT; an ASTRONOMER becomes a MOON STARER. The pleasure comes from preserving the letters while changing, or illuminating, the meaning. These are examples of wordplay, not claims of original authorship.
| Starting expression | Anagram | Meaning connection |
|---|---|---|
| LISTEN | SILENT | Listening and silence belong together. |
| ASTRONOMER | MOON STARER | A playful description of an observer of the sky. |
| THE EYES | THEY SEE | The phrase states what eyes do. |
| BINARY | BRAINY | A computing word turns into a compliment. |
| THE MORSE CODE | HERE COME DOTS | The rearrangement hints at the code’s dots. |
A useful trap: ANGEL → ANGELS
Not an anagram: ANGELS adds an S. A natural-looking related word is not enough.
3. A game that does not translate literally
Translating meaning does not preserve letters. LISTEN and SILENT form an English anagram; their French translations, écouter and silencieux, do not. Each edition therefore uses local examples instead of mechanically translating a list.
Our opening pair is an unusual exception: English LOGARITHM/ALGORITHM, Italian LOGARITMI/ALGORITMI, French LOGARITHME/ALGORITHME and Spanish LOGARITMO/ALGORITMO each work within their own language. However, their lengths and repetitions differ, so their combinatorial counts differ too.
These further English examples show how a phrase can supply a witty description, or even an arithmetic connection, while keeping exactly the same letters.
| Starting expression | Anagram | Meaning connection |
|---|---|---|
| ASTRONOMER | MOON STARER | An astronomer becomes someone staring at the Moon. |
| DORMITORY | DIRTY ROOM | An untidy description of a dormitory. |
| ELEVEN PLUS TWO | TWELVE PLUS ONE | Both sums equal 13: 11 + 2 = 12 + 1. |
4. How many arrangements can we build?
For four different letters there are four choices for the first position, three for the second, two for the third and one for the last. Multiply because these are successive stages of one construction.
n! is read as n factorial: the product of the integers from 1 to n; by convention 0! = 1. The count includes the original word. Subtract one if the question excludes its original arrangement.
The 24 arrangements of EAST are not 24 English words. EAST, EATS, SEAT, SATE and TEAS are recognizable; many other arrangements mean nothing. The formula counts letter strings, not dictionary entries.
EAST: 4 × 3 × 2 × 1 = 4! = 24
5. Repeated letters: why division is necessary
Imagine temporarily labelling LEVEL’s two Ls and two Es. There would be 5! arrangements of five distinguishable tiles. But swapping the L labels changes no visible word, and neither does swapping the E labels: each visible arrangement is counted 2! × 2! times.
In general, n letters with multiplicities n₁, n₂, …, nₖ, whose sum is n, require division by the factorial of each multiplicity. We are not dividing by how many letters are repeated, but by how many invisible exchanges each repeated group permits.
P = n! / (n₁! × n₂! × … × nₖ!)
LEVEL: 5! / (2! × 2!) = 30
LOGARITHM: 9! = 362880
6. Combinatorial growth and the link to algorithms
Factorials grow much faster than their first values suggest. Adding another distinct letter multiplies the total by the new number of positions. Producing every arrangement merely to check one proposed pair is therefore excessive work.
LOGARITHM and ALGORITHM also suggest a conceptual link: binary search repeatedly halves an ordered space of candidates, with the number of halvings growing like log₂ n. Ten halvings reduce 1024 possibilities to one. This connection between concepts is not evidence that the words share an etymology.
| All-distinct letters | Arrangements |
|---|---|
| 4 | 24 |
| 6 | 720 |
| 8 | 40,320 |
| 10 | 3,628,800 |
| 12 | 479,001,600 |
| 15 | 1,307,674,368,000 |
7. How a computer checks an anagram
One check sorts the letters of both expressions and compares the results. The sorted sequence acts as a signature: matching sequences contain the same letters with the same multiplicities.
Another check counts. Increase counters while reading the first word and decrease them while reading the second. Every counter must end at zero. Adding letter codes is not a safe signature: A+D and B+C have the same ASCII-code sum but different letters.
For the cost comparison, n is the total normalized input length and k the chosen alphabet size. Counting takes O(n+k), which becomes O(n) for a fixed alphabet. More complex scripts require a careful definition of a letter; normalization is not permission to erase linguistic distinctions.
LISTEN → EILNST
SILENT → EILNST
| Letter | First word | Second word |
|---|---|---|
| E | 1 | 1 |
| I | 1 | 1 |
| L | 1 | 1 |
| N | 1 | 1 |
| S | 1 | 1 |
| T | 1 | 1 |
| Method | Work required | Why |
|---|---|---|
| Generate every arrangement | Factorial for distinct letters | Explores many irrelevant candidates to check just one pair. |
| Sort and compare | O(n log n) with an efficient comparison sort | Places matching letters at matching positions. |
| Compare frequencies | O(n+k), or O(n) for a fixed alphabet | Visits the letters and compares k counters. |
CHECK(s, t)
s ← PREPARE(s); t ← PREPARE(t)
if length(s) ≠ length(t): return FALSE
counters ← zeros for every allowed letter
for each letter c in s: counters[c] += 1
for each letter c in t: counters[c] -= 1
return ALL_ZERO(counters)
More about frequency counting: Princeton · Count.java
8. Finding is not the same as checking
Checking a proposal means testing a precise constraint. Inventing a new sentence also involves vocabulary, word combinations and meaning. Nevertheless, a program need not blindly enumerate all permutations.
A dictionary can be indexed by signature, grouping words with identical counts. To build a phrase, choose a compatible word, subtract its letters from the available inventory and continue. Abandon a branch as soon as it requests an unavailable letter: that is pruning. Returning to an earlier decision to try another option is backtracking.
Results depend on the dictionary and rules: proper names, inflections and rare words may be allowed or excluded. Failure to find a phrase in one word list does not prove that no such phrase exists in the language.
9. Humans, computers and artificial intelligence
Computational thinking appears when we separate preparation, counting, checking and judging meaning. Humans and machines do not need to perform identical tasks.
AI may suggest themes and wording, yet a persuasive sentence can quietly introduce an extra letter. A deterministic frequency check must test the linguistic proposal. Creativity and verification help one another; neither replaces the other.
| Problem | Human contribution | Computer contribution |
|---|---|---|
| Choose the rules | Defines language, accents and allowed words. | Applies identical preparation to every input. |
| Check a pair | Explains why the test answers the question. | Compares every frequency without trusting meaning. |
| Find candidates | Suggests themes, humour and connections. | Searches the dictionary and prunes impossible branches. |
| Assess a sentence | Judges fluency, context and appropriateness. | Offers suggestions and checks without replacing editorial judgement. |
10. Galileo: hiding a discovery in letters
In 1610 Galileo communicated an observation of Saturn through an anagram, concealing its content while claiming priority. The revealed sentence described the planet as triple: his telescope did not clearly resolve its rings.
This is a historical use of anagrams, not a modern way to secure data: rearrangement exposes the letter inventory and does not guarantee a unique interpretation.
Historical context: Mario Biagioli · From ciphers to confidentiality; Museo Galileo · Saturno.
11. Six challenges: try before revealing
Solutions start hidden. Before opening them, write down what stays unchanged and which formula or algorithm the question actually needs.
1. Check LISTEN / SILENT: what sorted signature and frequencies do you get?
Show solution and reasoning
LISTEN → EILNST
SILENT → EILNSTThe signature matches because every letter occurs equally often.
2. How many distinct arrangements does EAST have? Are they all words?
Show solution and reasoning
EAST: 4! = 24The count includes the original and meaningless strings; dictionary filtering is a separate step.
3. How many distinct arrangements does LEVEL have? Why is n! too large?
Show solution and reasoning
LEVEL: 5! / (2! × 2!) = 30Swapping identical copies creates no new visible arrangement, so divide by the factorials of the multiplicities.
4. AAB and ABB use the same kinds of letters. Are they anagrams?
Show solution and reasoning
AAB: A=2, B=1
ABB: A=1, B=2No. AAB has two As and one B; ABB has one A and two Bs. Equal length and equal sets of letter types do not suffice.
5. How many arrangements of EAST begin with E?
Show solution and reasoning
3! = 3 × 2 × 1 = 6With the first letter fixed, three different letters remain: 3! = 6.
6. AI suggests a wonderfully clever phrase. How do you decide whether it is an exact anagram?
Show solution and reasoning
State the rules, normalize both texts and compare lengths and frequencies. If they match, check grammar and meaning. Otherwise correct the phrase, however witty it sounds.
12. An idea worth keeping
Anagrams teach a lesson larger than the game: changing representation can make an apparently huge problem simple. We need not generate millions of sentences to compare two inventories, nor mistake a possible arrangement for a meaningful word.
Mathematics counts, computing organizes, language supplies meaning and creativity discovers connections. The final check remains a small, exact question: did we use precisely the same letters?