Anagrams: Difference between revisions
Content added Content deleted
(→{{header|Common Lisp}}: use libheader) |
|||
Line 199: | Line 199: | ||
void main() { |
void main() { |
||
string[][string] anags; |
string[][string] anags; |
||
foreach (string w; new BufferedFile("unixdict.txt")) |
|||
anags[w.dup.sort] ~= w.dup; |
|||
int lmax; |
int lmax; |
||
foreach ( |
foreach (string w; new BufferedFile("unixdict.txt")) { |
||
string wrd = w.dup; |
|||
string key = wrd.sort; |
|||
⚫ | |||
anags[key] ~= wrd; |
|||
int len = anags[key].length; |
|||
lmax = lmax < len ? len : lmax; |
|||
} |
|||
⚫ | |||
if (a.length == lmax) { |
|||
writefln(a); |
writefln(a); |
||
} |
|||
} |
|||
} |
} |
||
</lang> |
</lang> |