RosettaCodeData/Task/Ordered-words/D/ordered-words-1.d
2015-02-20 00:35:01 -05:00

20 lines
475 B
D

void main() {
import std.stdio, std.algorithm, std.range, std.string;
string[] result;
size_t maxLen;
foreach (string word; "unixdict.txt".File.lines) {
word = word.chomp;
immutable len = word.walkLength;
if (len < maxLen || !word.isSorted)
continue;
if (len > maxLen) {
result = [word];
maxLen = len;
} else
result ~= word;
}
writefln("%-(%s\n%)", result);
}