Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
14
Task/Anagrams/Component-Pascal/anagrams-3.component
Normal file
14
Task/Anagrams/Component-Pascal/anagrams-3.component
Normal 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));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue