Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,24 +1,29 @@
|
|||
// We add a zero to be able to express e.g. "not top floor"
|
||||
def floors: [0..5 -> (floor:$)];
|
||||
def names: [['Ground', 'Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith']... -> (name:$)];
|
||||
permutations templates
|
||||
when <|=1> do [1] !
|
||||
otherwise
|
||||
n is $;
|
||||
expand templates
|
||||
p is $;
|
||||
1..$n -> templates
|
||||
k is $;
|
||||
[$p(..$k - 1)..., $n, $p($k..)...] !
|
||||
end !
|
||||
end expand
|
||||
$n - 1 -> # -> expand !
|
||||
end permutations
|
||||
|
||||
def dwellings: [$floors, $names] -> \(
|
||||
def solver: $ -> EinsteinSolver;
|
||||
names is ['Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith'];
|
||||
|
||||
{name: 'Ground', floor: 0} -> !solver::isFact
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Baker'}) -> !VOID
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..5]} {name: 'Cooper'}) -> !VOID
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..4]} {name: 'Fletcher'}) -> !VOID
|
||||
({name: 'Cooper'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Miller'}) -> !VOID
|
||||
({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Smith'}) -> !VOID
|
||||
({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Cooper'}) -> !VOID
|
||||
|
||||
[$solver::solutions&{required: 6} ... -> ($ notMatching {| {name: 'Ground'} |})]!
|
||||
\);
|
||||
|
||||
$dwellings -> \[i]('Solution $i;:
|
||||
$... -> '$;
|
||||
';
|
||||
'! \)... -> !OUT::write
|
||||
'No more solutions
|
||||
' -> !OUT::write
|
||||
5 -> permutations -> $names($)
|
||||
-> if <|?($(.. as i; -> if <|='Baker'> -> $i)... matches <~|=5>)>
|
||||
-> if <|?($(.. as i; -> if <|='Cooper'> -> $i)... matches <~|=1>)>
|
||||
-> if <|?($(.. as i; -> if <|='Fletcher'> -> $i)... matches <~|=1|=5>)>
|
||||
-> templates
|
||||
miller is $(.. as i; -> if <|='Miller'> -> $i)...;
|
||||
$ -> if <|?($(.. as i; -> if <|='Cooper'> -> $i)... matches <|..$miller>)> !
|
||||
end
|
||||
-> if <|?(($(.. as i; -> if <|='Smith'> -> $i)...) - ($(.. as i; -> if <|='Fletcher'> -> $i)...) matches <~|=1|=-1>)>
|
||||
-> if <|?(($(.. as i; -> if <|='Cooper'> -> $i)...) - ($(.. as i; -> if <|='Fletcher'> -> $i)...) matches <~|=1|=-1>)>
|
||||
-> $(.. as i; -> '$i;:$;$#10;')
|
||||
-> $(..:-1)
|
||||
-> '$...;$#10;' !
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
// We add a zero to be able to express e.g. "not top floor"
|
||||
def floors: [0..5 -> (floor:$)];
|
||||
def names: [['Ground', 'Baker', 'Cooper', 'Fletcher', 'Miller', 'Smith']... -> (name:$)];
|
||||
|
||||
def dwellings: [$floors, $names] -> \(
|
||||
def solver: $ -> EinsteinSolver;
|
||||
|
||||
{name: 'Ground', floor: 0} -> !solver::isFact
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Baker'}) -> !VOID
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..5]} {name: 'Cooper'}) -> !VOID
|
||||
({name: 'Ground'} solver::nextTo&{byField: :(floor:), bMinusA: [2..4]} {name: 'Fletcher'}) -> !VOID
|
||||
({name: 'Cooper'} solver::nextTo&{byField: :(floor:), bMinusA: [1..4]} {name: 'Miller'}) -> !VOID
|
||||
({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Smith'}) -> !VOID
|
||||
({name: 'Fletcher'} solver::nextTo&{byField: :(floor:), bMinusA: [-4..-2, 2..4]} {name: 'Cooper'}) -> !VOID
|
||||
|
||||
[$solver::solutions&{required: 6} ... -> ($ notMatching {| {name: 'Ground'} |})]!
|
||||
\);
|
||||
|
||||
$dwellings -> \[i]('Solution $i;:
|
||||
$... -> '$;
|
||||
';
|
||||
'! \)... -> !OUT::write
|
||||
'No more solutions
|
||||
' -> !OUT::write
|
||||
Loading…
Add table
Add a link
Reference in a new issue