RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/D/dinesmans-multiple-dwelling-problem-2.d
2023-07-01 13:44:08 -04:00

13 lines
533 B
D

void main() {
import std.stdio, std.math, std.algorithm, permutations2:permutations;
["Baker", "Cooper", "Fletcher", "Miller", "Smith"]
.permutations
.filter!(s =>
s.countUntil("Baker") != 4 && s.countUntil("Cooper") != 0 &&
s.countUntil("Fletcher") != 0 && s.countUntil("Fletcher") != 4 &&
s.countUntil("Miller") > s.countUntil("Cooper") &&
abs(s.countUntil("Smith") - s.countUntil("Fletcher")) != 1 &&
abs(s.countUntil("Cooper") - s.countUntil("Fletcher")) != 1)
.writeln;
}