# A Hobbyist Cracks Anagram Indexing Down to 11 Nanoseconds per Word

Original title: 11 Nanoseconds per Word: Over-Optimizing Anagrams

> Hacker News story 50363353 · language: en · submitted 2026-11-04
> Web version: https://zeli.app/story/50363353
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 36 · by [ColinWright](<https://news.ycombinator.com/user?id=ColinWright>) · 💬 5
[original](<https://wiredream.com/anagram-fun/>) · [HN discussion](<https://news.ycombinator.com/item?id=50363353>)

## Summary

When a Word Ladder solver took over a second to run, David G. Andersen rewrote it in Rust and kept optimizing. He starts at 173 nanoseconds per word, strips out Vec allocations, swaps string sorting for packed letter counts, and lands on a collision-free 64-bit prime-product key that fits every Scrabble word. Tuned primes and a fixed-length loop bring it to 11 nanoseconds per word, roughly 15 times faster than the baseline.

## Key quote

> We've found a collision-free canonical 64-bit identifier for the bag of letters in a (Scrabble) word.

## HN discussion (5 comments)

### [crab2](<https://news.ycombinator.com/item?id=50377775>)

> What metric best captures the anagram potential of a given set of letters in a given language? One way to solve this problem I can think of is to enumerate, at least partially, the anagrams that can be formed. Then you can come up with a density : nb_of_valid_anagrams / nb_explored_permutations. Why not. But I bet there are more insightful techniques.

### [wood_spirit](<https://news.ycombinator.com/item?id=50375657>)

> This reminds me fondly of things I used to do for programming contests :)
>
> I think I did an anagram dictionary once.  My memory is that I computed the anagrams once ever and made a dictionary file which was a sorted word list and the offset of the next anagram of that word.  The sorted letters for each anagram group were also in the same list.  Because it was searching for multiple word phrases you just did a search on the subsets of letters left for candidates.
>
> Scrabble dictionaries were the most mind bending I think.  I don’t think I wrote anagrams up but  this is the scrabble one https://williame.github.io/post/87682811573.html

### [mrandish](<https://news.ycombinator.com/item?id=50376095>)

> \> that I hadn't seen before (though the history of computing is long and Knuth probably noticed it in 1965).
>
> I love that aside. Probably would make a good T-shirt or bumper sticker, like: "Congrats on that clever algorithm you just came up with! Just remember... the history of computing is long and Knuth probably noticed it in 1965.

---

## Cite

- Page: https://zeli.app/story/50363353
- Date: 2026-11-04
- Source: wiredream.com (https://wiredream.com/anagram-fun/)
- Hacker News: https://news.ycombinator.com/item?id=50363353

## Other languages

- zh: https://zeli.app/zh/story/50363353 · markdown: https://zeli.app/zh/story/50363353.md
- ja: https://zeli.app/ja/story/50363353 · markdown: https://zeli.app/ja/story/50363353.md
- ko: https://zeli.app/ko/story/50363353 · markdown: https://zeli.app/ko/story/50363353.md
- de: https://zeli.app/de/story/50363353 · markdown: https://zeli.app/de/story/50363353.md
- es: https://zeli.app/es/story/50363353 · markdown: https://zeli.app/es/story/50363353.md
- ru: https://zeli.app/ru/story/50363353 · markdown: https://zeli.app/ru/story/50363353.md
