This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,14 @@
import std.stdio, std.algorithm, std.file, std.string;
void main() {
auto keys = cast(char[])"unixdict.txt".read;
immutable vals = keys.idup;
string[][string] anags;
foreach (w; keys.splitter) {
immutable k = cast(string)w.representation.sort().release;
anags[k] ~= vals[k.ptr-keys.ptr .. k.ptr-keys.ptr + k.length];
}
//immutable m = anags.byValue.max!q{ a.length };
immutable m = anags.byValue.map!q{ a.length }.reduce!max;
writefln("%(%s\n%)", anags.byValue.filter!(ws => ws.length == m));
}