Anagrams: Difference between revisions

Content deleted Content added
added sample output
Line 1: Line 1:
{{task|Text processing}}
{{task|Text processing}}
Two or more words can be composed of the same characters, but in a different order. Using the word list at http://www.puzzlers.org/pub/wordlists/unixdict.txt, find the sets of words that share the same characters that contain the most words in them.
Two or more words can be composed of the same characters, but in a different order. Using the word list at http://www.puzzlers.org/pub/wordlists/unixdict.txt, find the sets of words that share the same characters that contain the most words in them.

== {{header|D}} ==

D 1, using Phobos.
<d>
import std.stdio, std.stream;

void main() {
string[][string] anags;
foreach (string w; new BufferedFile("unixdict.txt"))
anags[w.dup.sort] ~= w.dup;
int lmax;
foreach (a; anags)
lmax = lmax < a.length ? a.length : lmax;
foreach (a; anags)
if (a.length == lmax)
writefln(a);
}
</d>


== {{header|Haskell}} ==
== {{header|Haskell}} ==