RosettaCodeData/Task/Ordered-words/D/ordered-words-2.d

20 lines
485 B
D
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
void main() {
2014-01-17 05:32:22 +00:00
import std.stdio, std.algorithm, std.file, std.range;
2015-02-20 00:35:01 -05:00
2013-04-10 16:57:12 -07:00
string[] result;
size_t maxWalkLen;
2014-01-17 05:32:22 +00:00
foreach (word; "unixdict.txt".readText.splitter) {
if (word.length >= maxWalkLen && word.isSorted) {
immutable wlen = word.walkLength;
2013-04-10 16:57:12 -07:00
if (wlen > maxWalkLen) {
result.length = 0;
maxWalkLen = wlen;
}
result ~= word.idup;
}
}
writefln("%-(%s\n%)", result);
}