235 comments

[ 5.0 ms ] story [ 73.5 ms ] thread
Tldr:

Rewrite all words so the letters in each word are rearranged alphabetically. Don't do this other thing suggested on StackExchange

Look at the list of anagrams

Recognize that the list is actually boring

Get silly with words and nerd out

The end!

uh, you forgot the actual tl;dr, which is

     cinematographer --> megachiropteran
> regulation urogenital

Eyeballed the entire list*. This is the most 2023 one I could find.

(*no)

That was pretty good for a one-word anagram. Back in the 1990s I wrote a program that generated anagrams for longer phrases and I was surprised to find these prescient ones:

Saddam Hussein = He damns Saudis

Charles Manson = Slasher con man

David Letterman = Dead mitral vent

Mary Jo Kopechne = My joke chaperon *

Benito Mussolini = So, I bout Leninism

Lee Harvey Oswald = Oe, why ever Dallas? *

* "Chaperon" is a valid alternate spelling of "chaperone"

** Yes, "oe" is a word

Ronald Wilson Reagan = Insane Anglo Warlord
Dick Cavett, https://www.nytimes.com/2018/08/04/style/dick-cavett-intervi...

> I guess I’ll be known for nothing more than being the man who realized that “Spiro Agnew” was “grow a penis.” Gore Vidal said, “It could be ‘grow a spine,’ too, but yours is better.”

Boy, they're really socking it to that Spiro Agnew guy again.

His pal Richard Milhous Nixon = Nix Hanoi child rumors
That's why they're called nattering nabobs of negativism.
Also "Orwellian radon snag"
Clint Eastwood = Old West Action is still my favorite serendiptious anagram.

I also like the mathematically correct

ELEVEN PLUS TWO = TWELVE PLUS ONE

especially because it's also an numeric anagram

11 + 2 = 12 + 1

Mother in law = Woman Hitler is another classic
Does that count as Godwinning the anagrams discussion?
Godwin’s law = wild wagons
Things like that explain how some people get obsessed with numerology. Except, I find the anagrams like you and the previous commenter mentioned to be more impressive than anything numerologists produce.

Some of those are almost creepy in how they make so much sense.

We're pattern matching machines, if you throw enough randomness at us we will find patterns anyway.

Probably because looking at evolution it's more helpful to see a predator that isn't there, than to miss a predator that is there. It intuitively makes sense that we would tilt towards false positives over false negatives in our perception. Since one has a higher cost attached than the other.

Which is why I find some of the discussion arround whether GPTs are intelligent interesting. I see the argument quite often that they merely match patterns and combine things. Which to me seems very much akin to us. They lack the ability to interact with the world and there is no feedback loop as of now, but it seems to me that there is something very human to the AI we programmed.

The Spanish translation of this is ONCE MAS CUATRO = CATORCE MAS UNO (11 + 4 = 14 + 1).
Which (including spaces) is 15 characters long :)
Yeah but chaperon would be masculine and chaperone feminine.
Ted Kennedy, her "chaperon," was male, so it works perfectly. Although I don't think the difference between the spellings is a gender thing, but rather a British/American thing.
I did Wikipedia article titles and found:

Atlantic casino resort spa / Carter assassination plot

That would make an excellent 'not to be confused with'.
How many generated anagrams do you have to skim through to find these gems? Was the program written in a way that limits the output to phrases that make at least some sense?
It had features for things like limiting output to anagrams that contain a maximum number of words, or words with a minimum length, so you wouldn't have to slog through every permutation. Usually the most interesting ones had the fewest words. But "interesting" is subjective so if you really wanted to find juicy ones you would have to spend more time combing through the results by hand.

You can find the documentation, a Win32 executable, and the source code here: https://www.kmoser.com/anagrams/

The most remarkable name anagram for me remains that of 1990s UK conservative Health Secretary and government minister Virginia Bottomley (now Baroness Bottomley of Nettlestone), whose name rearranges to “I’m an evil Tory bigot”.

In terms of this ‘chunk scoring’ method this scores very high (15 I think?), which definitely confirms its value as a way of rating anagram quality.

[flagged]
It just searched Bing and loaded up this very article. And man I'm getting really sick of the unrelated ChatGPT comments on literally every post, no offense.
OK, fair enough. I will stop doing it. I get down voted a lot for it :)
I apologize for the snarky comment, I guess I just have GPT fatigue.
Jeremy’s Iron
Tell me you’re a millennial who grew up watching The Simpsons without etc etc.
Actually early genx. I don’t think most millennials were old enough for a lot of the jokes in 90’s simpsons as they were young teens. But glad you got it!
“Are you being sarcastic, dude?”

I was born in 1982, and a lot of the humor went over my head til much later. But the first ten seasons or so are still indelibly etched in my memory.

What’s nostalgic to me is that this is such a classic Perl pattern: hashing manipulated strings to find relationships. Prior to Perl doing this was painful. Boost wasn’t a thing. Python was in its cradle and Java was still struggling with beans. Perl removed the barriers between complex coding ideas and an implementation that C wasn’t ready for. The time from thought to prototype was near instant compared to current compiled languages.
Ummm, the author used awk for the first version in the 1990s.

> This was easy to do, even at the time, when the word list itself, at 2.5 megabytes, was a file of significant size. Perl and its cousins were not yet common; in those days I used Awk. But the task is not very different in any reasonable language:

I know. I’m talking about Perl. Try to keep up.
Do pay attention.

You wrote "Prior to Perl doing this was painful.".

I highlighted how you contradicted the author's claim that it was easy to do using awk. Awk existed long before Perl.

As a concrete example, while my awk skills are extremely rusty, here's a program which will normalize the input line, create a table mapping the normalized name to the matching original lines, then at the end it only displays the ones with at least 5 anagrams.

I tried to avoid modern awk features, like asort, to be something that would have worked in the 1980s:

  {
      # Convert to normal form:
      #  1. Fold to lower case
      #  2. Bin the letters to get frequency counts
      #  3. Only consider lower case ASCII letters
      split(tolower($0), letters, "");
  
      # Ignore asort() in modern awks and do a bin sort instead.
      for (i in letters) {
          c = letters[i];
          repeats[c] = repeats[c] c;
      }
  
      normal_form = "";
      for (i=97; i<=122; i++) {
          c = sprintf("%c", i); # no chr() in a 1980s awk
          normal_form = normal_form repeats[c];
      }
  
      table[normal_form] = table[normal_form] "," $0
      delete repeats;
  }
  END {
      # Only show the ones with at least 5 matches
      for (i in table) {
          match_str = table[i];
          split(match_str, matches, ",");
          num_matches = length(matches)-1
          if (num_matches >= 5) {
              # print the number of matches, then the match string
              printf("%d%s\n", num_matches, match_str);
          }
      }
  }
When I try it on a word list I have handy, here are the most common words:

  % awk -f anagram.awk < words_alpha.txt | sort -n -t, | tail -5
  13,elaps,lapse,leaps,lepas,pales,peals,pleas,salep,saple,sepal,slape,spale,speal
  14,anestri,antsier,asterin,eranist,nastier,ratines,resiant,restain,retains,retinas,retsina,stainer,starnie,stearin
  14,apers,apres,asper,pares,parse,pears,prase,presa,rapes,reaps,repas,spaer,spare,spear
  14,arest,aster,astre,rates,reast,resat,serta,stare,strae,tares,tarse,tears,teras,treas
  15,alerts,alters,artels,estral,laster,lastre,rastle,ratels,relast,resalt,salter,slater,staler,stelar,talers
Certainly Perl is more succinct, though note that even up to Perl 4 in the early 1990s you would need to use the string concatenation method to store the list of matches in the table.

But, "painful"? No. Not to someone who knew how to use awk.

You don't _need_ to hash anything.

The simplest way to do it, is to convert all the words to (normal_form, orig_word) pairs, write the list to a file, then sort it.

It will be trivial to find the words with common normal form after the sort.

(Of course, you wouldn't catch me trying to implement that with C if perl is an option...)

But the normal form as defined by the article is an hash, even if you then use sorting instead of bucketing
The point is that you don’t need a hash table implementation. And the normalization that is used as the sorting key doesn’t otherwise have good hash-like qualities (like constant size and a good distribution) and thus doesn’t especially deserve to be called a hash.
How do you extract the last (largest) entry for each normalized key from the sorted list? What is the command line function?
It can be a simple ~20 line C program that checks whether the previous line has the same normalized key as the current line. It doesn't require hashing. I didn't say you could do it all with standard unix programs.
You pipe the sorted list into awk (for example) and append the second field to a list as long as the value of the first field remains the same. Whenever the value of the first field changes, and in the END block, you output the list (which contains the matching anagrams) and reset it to empty.

No hash table needed, just splitting the line into the two fields, equality comparison, and appending values to a list.

Go try your method and spot the bug. If you can’t, then respond and I’ll tell you. hint: you need one more manipulation to find the answer before or after the sort, there’s a command line version of it but it uses .. a hash.
Even in C it’s not that hard to make a basic hash table. It’s probably like 20 lines of code or something.
I thought integrals / triangles was much more interesting, despite the shorter length. None of the other long pairs have any meaningful relationship, except for maybe excitation / intoxicate
What you don't think all married people are admirers of sidearms /s

> 7 admirer married > 7 admires sidearm

This one reminded me of those captcha cartoons that were popular for awhile. “Admires sidearm” in curved writing and a simple drawing.
It seemed to me that integral/triangle (singular) should really get the same score.
Feels like the edit distance algorithm would be the natural fit here for scoring.
How does that do on the longest example found by the author, which he (correctly IMO) dismisses as uninteresting?

cholecystoduodenostomy / duodenocholecystostomy

Trigram overlap is a better measure.
Scored by Levenenshtein distance, that is still fourth-highest.
(comment deleted)
I don't know why, but I really like soapstone teaspoons.
I will counter that with.. timesaving negativism.
I’ve seen better.
That one has real meaning too. Being naturally inclined to mentally run through all the worst case scenarios for everything has definitely saved me time over the years.
Over the long run, minimizing the maximally worst cases works.
I think the best anagrams are the ones that create meaningful phases, I would probably train a SVM or a simple linear layer on BERT (or other encoder) embeddings and use it to score the results.
Some of my favorite pairs from the big list:

misrelation / orientalism; superintended / unpredestined; incorporate / procreation (don't mind if i do!); predators / teardrops (a cause and effect); counteridea / reeducation (a bit synonymous); streamlined / derailments (quite opposite!); truculent / unclutter; colonialist / oscillation; renavigate / vegetarian; persistent / prettiness; paternoster / penetrators (hmm); obscurantist / subtractions; nectarines / transience (a story of ripeness); definability / identifiably; indiscreet / iridescent; excitation / intoxicate; discounter / reductions (how logical!)

One small suggestion I have: add a point for pairs with different starting letters, and another point for pairs with different ending letters.

Also "Xenoparasite Exasperation" - would have made a great title for a 1960s/70s Sci-Fi B movie...
> I wouldn't have mentioned this, but someone on StackExchange actually asked this question.

I wonder if the author realizes how condescending this is.

I'm listening. Please explain.
imo interpretation of actually as "I can't believe someone did this (that someone could be so stupid)" rather than actually as "this is an event that definitely occured". Didn't seem too bad to me.
You basically said, “Can you believe someone actually was so stupid as to ask this question on stackexchange? I didn’t believe anyone could actually be that stupid, so I wasn’t go to address it, but it turns out there actually are people that stupid, and they actually outed themselves by posting their question out in the open! So, here I am having to address it in my blog post in case there are other people who actually are equally stupid.”
I’m pretty sure I wrote an anagram solver as a teenager that just spins through permutations forever. I guess I was that stupid once. No comment on whether I’m cured now. Your point is valid, the wording can be read as to imply negativity, but that’s also interpreting it in a negative light. The author was also defending his warning against an imaginary rebuttal, justifying the mention to not to waste time solving anagrams the naive brute force way. I don’t think he was trying to be elitist or offensive, and it is in fact true that people will solve anagrams the slow way, so doesn’t hurt to mention it, and it can even help on occasion. We don’t have to take it as condescending.
I didn't “basically” say any of that. I didn't say any of it at all; you made it all up and then attributed it to me. All I actually did was to state a fact: someone on StackExchange actually asked this question.

All those thoughts about what a stupid question it is, and how stupid someone must have been to ask it—all those are thoughts you had, not me.

FWIW, I also originally read that line to imply "I thought this was obvious, but apparently I need to be explicit anyway".

Given the tone of the rest of the article I assumed that I'd either read something into it that wasn't there or was missing some context - for example, perhaps the person on SO had insisted that this was the correct approach, and you'd gone to some lengths to show that it was not and were exasperated by it by the time you wrote the article.

At any rate - it didn't really take away from your article for me, but I did see it as condescending.

Thanks for letting me know.
While I personally agree with the end result - cinematographer megachiropteran possibly being the best anagram, its worth exploring other scoring mechanisms I suppose - some kind of alliteration / cadence score to quantify how the words roll in succession. Maybe throw in semantic distance as well using clip embeddings probably to quantify the surprise element (or closeness for that matter). Gonna play around with this and see what I can do.
This is great! It reminds me of a Tom7 video of a similar ilk: Anagrams, but where you can break apart letters: "Anagraphs" - https://www.youtube.com/watch?v=qTBAW-Eh0tM.

Similar to this, he produces a standard form for each word, but breaks each letter into letter pieces or 'atoms' which gives much more freedom for moving between words.

Definitely give it a watch. If you are not familiar with Tom7's videos, he has a hilarious whimsical style while also bringing to life completely out there ideas with some brilliant technical skill.

Megachiropterans are fruit bats. They are really stinking adorable, especially when compared to smaller insect-eating bats, and for that reason are sometimes called flying foxes. In short, they make good subjects for cinematographers.
One of the longest anagrams I know that doesn't involve obscure medical words is "astronomers" and "moon starers." Both of these phrases contain the same letters but in a different order, making them anagrams of each other. This anagram contains 11 letters and is quite interesting, as both phrases relate to looking up at the night sky and studying celestial bodies.

ChatGPT

The wordsmith link in my other comment tells me that one is a triple on that theme:

astronomers = moon starers = no more stars

> coprophagist

Now that's something...

Yeah, I wish I haadn't looked up the meaning.
The world, overcrowded and jostling itself with all of its masculine calumnies....
My personal favourite is that an anagram of Banach-Tarski is Banach-Tarski Banach-Tarski.
Just like in the original, I think it’s only going to work in theory.
It only has a score of 6 though, in the typical formulation.
Guess what the B in "Benoit B. Mandelbrot" stands for?
Given that he added that middle "initial" himself and he didn't actually have a middle name, I like thinking that he added it precisely to make that joke work. Probably not true, but I still like it.
I wonder whether someone made a similar effort for finding the "most rhyming" words in English. Of course, since this would be based on sound, it would need to incorporate additional information besides spelling.
It also starts a huge argument about what kinds of rhyming are permitted (visual, sound, which accent, etc) - and some languages “rhyme” on things we wouldn’t use in English like the emphasis, etc.