<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Anagrams</title>
	<atom:link href="http://programmingpraxis.com/2009/04/10/anagrams/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/04/10/anagrams/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Vikas Tandi</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-3001</link>
		<dc:creator><![CDATA[Vikas Tandi]]></dc:creator>
		<pubDate>Sat, 07 May 2011 15:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-3001</guid>
		<description><![CDATA[Here is my implementation in C
http://codepad.org/Xx6GE4vU]]></description>
		<content:encoded><![CDATA[<p>Here is my implementation in C<br />
<a href="http://codepad.org/Xx6GE4vU" rel="nofollow">http://codepad.org/Xx6GE4vU</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OraQA &#187; Blog Archive &#187; How to solve the Anagrams Puzzle in SQL</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-1306</link>
		<dc:creator><![CDATA[OraQA &#187; Blog Archive &#187; How to solve the Anagrams Puzzle in SQL]]></dc:creator>
		<pubDate>Tue, 08 Jun 2010 15:41:38 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-1306</guid>
		<description><![CDATA[[...] 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. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 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. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Finding all anagrams in a dictionary using a signature based algorithm &#124; Complete Coding</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-1007</link>
		<dc:creator><![CDATA[Finding all anagrams in a dictionary using a signature based algorithm &#124; Complete Coding]]></dc:creator>
		<pubDate>Fri, 12 Feb 2010 16:18:18 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-1007</guid>
		<description><![CDATA[[...] Phil from Programming Praxis had posted this problem in his post. You can also find the implementation in different languages.   Share/BookmarkRelated [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Phil from Programming Praxis had posted this problem in his post. You can also find the implementation in different languages.   Share/BookmarkRelated [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: An anagram measure &#171; Alasdair&#8217;s musings</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-650</link>
		<dc:creator><![CDATA[An anagram measure &#171; Alasdair&#8217;s musings]]></dc:creator>
		<pubDate>Wed, 30 Sep 2009 03:33:37 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-650</guid>
		<description><![CDATA[[...] From an anagrams programming page: [...]]]></description>
		<content:encoded><![CDATA[<p>[...] From an anagrams programming page: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhijith</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-424</link>
		<dc:creator><![CDATA[Abhijith]]></dc:creator>
		<pubDate>Tue, 04 Aug 2009 08:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-424</guid>
		<description><![CDATA[Improved version and shorter version.
[sourcecode lang=&#039;ruby&#039;]
 def anagram(file)  
   table = Hash.new { &#124;hash, key&#124; hash[key] = [] }
   
   File.open(file).each_line do &#124;word&#124; # assumes one word per line  
     unsorted = word.chomp             # get rid of \n  
     sorted = unsorted.split(&quot;&quot;).sort.join(&quot;&quot;)  
     table[sorted].push(unsorted)
   end  
   
   table  
 end  
   
 def longest_anagram_class(hash)  
   hash.sort_by { &#124;k, v&#124; -1 * v.length }.first.last  
 end  
   
 h = anagram(&quot;/usr/share/dict/words&quot;)  
 puts &quot;Longest anagram class #{longest_anagram_class(h).inspect}&quot;
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Improved version and shorter version.</p>
<pre class="brush: ruby;">
 def anagram(file)  
   table = Hash.new { |hash, key| hash[key] = [] }
   
   File.open(file).each_line do |word| # assumes one word per line  
     unsorted = word.chomp             # get rid of \n  
     sorted = unsorted.split("").sort.join("")  
     table[sorted].push(unsorted)
   end  
   
   table  
 end  
   
 def longest_anagram_class(hash)  
   hash.sort_by { |k, v| -1 * v.length }.first.last  
 end  
   
 h = anagram("/usr/share/dict/words")  
 puts "Longest anagram class #{longest_anagram_class(h).inspect}"
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhijith</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-390</link>
		<dc:creator><![CDATA[Abhijith]]></dc:creator>
		<pubDate>Wed, 22 Jul 2009 17:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-390</guid>
		<description><![CDATA[[sourcecode lang=&#039;ruby&#039;]
def anagram(file)
  table = []

  File.open(file).each_line do &#124;word&#124; # assumes one word per line
    unsorted = word.chomp             # get rid of \n
    sorted = unsorted.split(&quot;&quot;).sort.join(&quot;&quot;)
    if table.has_key?(sorted)
      table[sorted].push(unsorted)
    else
      table[sorted] = [].push(unsorted)
    end
  end

  table
end

def longest_anagram_class(hash)
  hash.sort_by { &#124;k, v&#124; -1 * v.length }.first.last
end

h = anagram(&quot;/usr/share/dict/words&quot;)
puts &quot;Longest anagram class #{longest_anagram_class(h).inspect}&quot;

[/sourcecode]
output:
=&gt; Longest anagram class [&quot;angor&quot;, &quot;argon&quot;, &quot;goran&quot;, &quot;grano&quot;, &quot;groan&quot;, &quot;nagor&quot;, &quot;orang&quot;, &quot;organ&quot;, &quot;rogan&quot;]]]></description>
		<content:encoded><![CDATA[<pre class="brush: ruby;">
def anagram(file)
  table = []

  File.open(file).each_line do |word| # assumes one word per line
    unsorted = word.chomp             # get rid of \n
    sorted = unsorted.split("").sort.join("")
    if table.has_key?(sorted)
      table[sorted].push(unsorted)
    else
      table[sorted] = [].push(unsorted)
    end
  end

  table
end

def longest_anagram_class(hash)
  hash.sort_by { |k, v| -1 * v.length }.first.last
end

h = anagram("/usr/share/dict/words")
puts "Longest anagram class #{longest_anagram_class(h).inspect}"

</pre>
<p>output:<br />
=&gt; Longest anagram class ["angor", "argon", "goran", "grano", "groan", "nagor", "orang", "organ", "rogan"]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kryptosfan</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-249</link>
		<dc:creator><![CDATA[kryptosfan]]></dc:creator>
		<pubDate>Tue, 30 Jun 2009 15:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-249</guid>
		<description><![CDATA[I&#039;m not much of a programmer but if we can look past that character deficit...  

Anyways, I&#039;m looking at the puzzle sculpture Kryptos and think the keywords can be retrieved from the Morse Code messages via anagramming.  I&#039;m trying to recruit help from folks with an interest in anagrams across Wordpress.  I kept the details brief because it&#039;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!]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not much of a programmer but if we can look past that character deficit&#8230;  </p>
<p>Anyways, I&#8217;m looking at the puzzle sculpture Kryptos and think the keywords can be retrieved from the Morse Code messages via anagramming.  I&#8217;m trying to recruit help from folks with an interest in anagrams across WordPress.  I kept the details brief because it&#8217;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!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Treaps &#171; Programming Praxis</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-224</link>
		<dc:creator><![CDATA[Treaps &#171; Programming Praxis]]></dc:creator>
		<pubDate>Fri, 26 Jun 2009 09:05:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-224</guid>
		<description><![CDATA[[...] we have used in several exercises (Mark V. Shaney, Word Frequencies, Dodgson&#8217;s Doublets, Anagrams). Hash tables are often used as the underlying implementation for dictionaries, and in a previous [...]]]></description>
		<content:encoded><![CDATA[<p>[...] we have used in several exercises (Mark V. Shaney, Word Frequencies, Dodgson&#8217;s Doublets, Anagrams). Hash tables are often used as the underlying implementation for dictionaries, and in a previous [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: g</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-73</link>
		<dc:creator><![CDATA[g]]></dc:creator>
		<pubDate>Tue, 21 Apr 2009 06:41:48 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-73</guid>
		<description><![CDATA[python:

&lt;pre&gt;

wordlist = [line.strip() for line in open(&quot;WORD.LST&quot;)]
dic = {}
for word in wordlist:
    dic.setdefault(len(word), set()).add(word)

def find_anagrams(str):
    anagrams = ()
    if len(str) in dic:
        for word in dic[len(str)]:
            match = True
            for letter in frozenset(str):
                if str.count(letter) != word.count(letter):
                    match = False
                    break
            if match:
                anagrams += word,
    return anagrams

def longest_anagram():
    anagrams = ()
    for key in dic:
        anagrams += tuple(find_anagrams(word) for word in dic[key])
    return max(anagrams, key=len)
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>python:</p>
<pre>

wordlist = [line.strip() for line in open("WORD.LST")]
dic = {}
for word in wordlist:
    dic.setdefault(len(word), set()).add(word)

def find_anagrams(str):
    anagrams = ()
    if len(str) in dic:
        for word in dic[len(str)]:
            match = True
            for letter in frozenset(str):
                if str.count(letter) != word.count(letter):
                    match = False
                    break
            if match:
                anagrams += word,
    return anagrams

def longest_anagram():
    anagrams = ()
    for key in dic:
        anagrams += tuple(find_anagrams(word) for word in dic[key])
    return max(anagrams, key=len)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: FalconNL</title>
		<link>http://programmingpraxis.com/2009/04/10/anagrams/#comment-62</link>
		<dc:creator><![CDATA[FalconNL]]></dc:creator>
		<pubDate>Fri, 10 Apr 2009 12:30:33 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=398#comment-62</guid>
		<description><![CDATA[In Haskell:

[sourcecode lang=&#039;css&#039;]
import Data.List
import GHC.Exts
import Control.Arrow
import Data.Map (Map, findWithDefault, fromList)

main = do words&#039; &lt;- fmap lines $ readFile &quot;words.txt&quot;
          print . last . sortWith length $ map (anagrams (anagramMap words&#039;)) words&#039;

anagramMap :: [String] -&gt; Map String [String]
anagramMap = fromList . map (sort . head &amp;&amp;&amp; id) . groupWith sort

anagrams :: Map String [String] -&gt; String -&gt; [String]
anagrams d s = findWithDefault [] (sort s) d
[/sourcecode]

Largest anagram class in my dictionary: [&quot;pares&quot;,&quot;parse&quot;,&quot;pears&quot;,&quot;rapes&quot;,&quot;reaps&quot;,&quot;spare&quot;,&quot;spear&quot;]]]></description>
		<content:encoded><![CDATA[<p>In Haskell:</p>
<pre class="brush: css;">
import Data.List
import GHC.Exts
import Control.Arrow
import Data.Map (Map, findWithDefault, fromList)

main = do words' &lt;- fmap lines $ readFile &quot;words.txt&quot;
          print . last . sortWith length $ map (anagrams (anagramMap words')) words'

anagramMap :: [String] -&gt; Map String [String]
anagramMap = fromList . map (sort . head &amp;&amp;&amp; id) . groupWith sort

anagrams :: Map String [String] -&gt; String -&gt; [String]
anagrams d s = findWithDefault [] (sort s) d
</pre>
<p>Largest anagram class in my dictionary: ["pares","parse","pears","rapes","reaps","spare","spear"]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

