Anagrams
April 10, 2009
Words that are formed from the same set of letters are anagrams of each other. For instance, pots, post, stop, spot, opts, and tops are anagrams.
Your task is to write a program that, given a dictionary and an input word, prints all the anagrams of the input word. You are also to determine the largest anagram class in your dictionary. When you are finished, you can read or run a suggested solution, or post your own solution or discuss the exercise in the comments below.
In Haskell:
Largest anagram class in my dictionary: [“pares”,”parse”,”pears”,”rapes”,”reaps”,”spare”,”spear”]
python:
[…] we have used in several exercises (Mark V. Shaney, Word Frequencies, Dodgson’s Doublets, Anagrams). Hash tables are often used as the underlying implementation for dictionaries, and in a previous […]
I’m not much of a programmer but if we can look past that character deficit…
Anyways, I’m looking at the puzzle sculpture Kryptos and think the keywords can be retrieved from the Morse Code messages via anagramming. I’m trying to recruit help from folks with an interest in anagrams across WordPress. I kept the details brief because it’s all available online. Besides help, I was wondering if there are anagram methods that work in an algorithmic method allowing you to systematically build a second plaintext message from the original. I may be grasping at straws here but I was hoping you and maybe your readers might have some direction for me as I feel rather lost. Thanks!
output:
=> Longest anagram class [“angor”, “argon”, “goran”, “grano”, “groan”, “nagor”, “orang”, “organ”, “rogan”]
Improved version and shorter version.
[…] From an anagrams programming page: […]
[…] Phil from Programming Praxis had posted this problem in his post. You can also find the implementation in different languages. Share/BookmarkRelated […]
[…] Anagrams Words that are formed from the same set of letters are anagrams of each other. For instance, pots, post, stop, spot, opts, and tops are anagrams. Your task is to write a program that, given a dictionary and an input word, prints all the anagrams of the input word. You are also to determine the largest anagram class in your dictionary. […]
Here is my implementation in C
http://codepad.org/Xx6GE4vU
https://github.com/ftt/programming-praxis/blob/master/20090410-anagrams/anagrams.py