Zebra puzzle: Difference between revisions

→‎{{header|Raku}}: update some match multi subs
(→‎{{header|Raku}}: update some match multi subs)
Line 6,135:
 
#| find all possible solutions for pairs of houses with
#| properties %ab, left of a house with properties %ba
multi sub match(@houses, :Left-Of(%ba)!, *%ab) {
for 1 ..^ @houses {
my $idx%left-house := .<num> @houses[$_- 1];
ifmy $idx > 0 && plausible(@houses[$idx%right-1],house %a):= && plausible(@houses[$idx_], %b) {;
temp @houses[$idx-1].Hash ,= %a;
if plausible(%left-house, %a) && temp @houses[$idx].Hash plausible(%right-house,= %b;) {
temp @houses[$idx%left-1].Hashhouse ,= %a;
temp %right-house ,= %b;
take @houses;
}
Line 6,155 ⟶ 6,157:
#| find all possible houses that match the given properties
multi sub match(@houses, *%props) {
for @houses.grep({plausible($_, %props)}) -> $%house {
mytemp $idx%house ,= $house<num> - 1%props;
temp @houses[$idx] = %( %$house, %props );
take @houses;
}
Anonymous user