I’ve been reading Clive Thompson’s Coders book, and it’s caused me to reflect upon the process I use for coming up with algorithms. I’ve come to realize this is one of those things which I do, but is incredibly difficult to explain to others– so this post is my effort to encapsulate “my process.”
- Become intrigued/obsessed with something (e.g. anagrams)
- Discover an online anagram finder
- Ask myself, “How would I go about building my own anagram finder?”
- Realize I have no idea, and beat myself up for not knowing
- Forget about building my anagram finder project
- Weeks later, coincidentally stumble across:
- Fermat’s notes on anagram comparison using prime numbers trick
- A code challenge to create anagram tester function
- Turn Fermat’s concept into a quick & dirty JavaScript function, areAnagrams().
- Feel good about my areAnagrams() milestone/accomplishment
- Realize Fermat approach hits integer bit-limit with medium length words.
- Convert areAnagrams() from prime numbers to “wordDNA” approach (i.e. case-insensitive letter sorting)
- Feel good about resolving limit in areAnagrams() function.
- Days later, realize wordDNA approach can be used to create a “rainbow table” of dictionary list– and now you’ve got the basic building parts of an online anagram finder.