Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Semordnilap/D/semordnilap-1.d
Normal file
19
Task/Semordnilap/D/semordnilap-1.d
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
void main() {
|
||||
import std.stdio, std.file, std.string, std.algorithm;
|
||||
|
||||
bool[string] seenWords;
|
||||
size_t pairCount = 0;
|
||||
|
||||
foreach (const word; "unixdict.txt".readText.toLower.splitter) {
|
||||
//const drow = word.dup.reverse();
|
||||
auto drow = word.dup;
|
||||
drow.reverse();
|
||||
if (drow in seenWords) {
|
||||
if (pairCount++ < 5)
|
||||
writeln(word, " ", drow);
|
||||
} else
|
||||
seenWords[word] = true;
|
||||
}
|
||||
|
||||
writeln("\nSemordnilap pairs: ", pairCount);
|
||||
}
|
||||
9
Task/Semordnilap/D/semordnilap-2.d
Normal file
9
Task/Semordnilap/D/semordnilap-2.d
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
void main() {
|
||||
import std.stdio, std.file, std.algorithm, std.string, std.range;
|
||||
|
||||
auto words = "unixdict.txt".readText.split.zip(0.repeat).assocArray;
|
||||
auto pairs = zip(words.byKey, words.byKey.map!(w => w.dup.reverse))
|
||||
.filter!(wr => wr[0] < wr[1] && wr[1] in words)
|
||||
.zip(0.repeat).assocArray;
|
||||
writeln(pairs.length, "\n", pairs.byKey.take(5));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue