Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
import std.stdio, std.math, std.algorithm, std.traits, std.array, permutations2:permutations;
|
||||
|
||||
void main() {
|
||||
|
||||
enum Names { Baker, Cooper, Fletcher, Miller, Smith }
|
||||
|
||||
immutable(bool function(in Names[]) pure nothrow)[] predicates = [
|
||||
s => s.countUntil(Names.Baker) != 4 && s.countUntil(Names.Cooper) != 0,
|
||||
s => s.countUntil(Names.Fletcher) != 4 && s.countUntil(Names.Fletcher) != 0,
|
||||
s => s.countUntil(Names.Miller) > s.countUntil(Names.Cooper),
|
||||
s => abs(s.countUntil(Names.Smith) - s.countUntil(Names.Fletcher)) != 1,
|
||||
s => abs(s.countUntil(Names.Cooper) - s.countUntil(Names.Fletcher)) != 1
|
||||
];
|
||||
|
||||
permutations([EnumMembers!Names]).filter!(solution => predicates.all!(pred => pred(solution)))
|
||||
.writeln;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue