10 my ($p1, $sign, $score, $p2) = /(\w+) would (\w+) (\d+) happiness units? by sitting next to (\w+)\./;
11 $sign = ($sign eq 'gain') ? 1 : -1;
12 $rules{$p1}{$p2} = $sign * $score;
19 my ($done, $rest) = @_;
22 for my $i (0 .. $#$rest) {
25 push @nd, splice @nr, $i, 1;
30 for my $i (0 .. $#$done) {
31 my $self = $done->[$i];
32 my @neigh = ($done->[$i-1], $done->[$i == $#$done ? 0 : $i+1]);
34 $score += $rules{$self}{$n};
37 $max = $score if !defined $max || $max < $score;
41 perm([], [ keys %persons ]);