All pastes #247193 Raw Edit

Miscellany

public text v1 · immutable
#247193 ·published 2006-11-13 03:27 UTC
rendered paste body
split /, /, ($_ . (chomp ($_ = <STDIN>)) x 0);
$u = 1 - ($l = 1 * (lc shift @_ eq 'l')) + ($m = shift @_) * 0;
$t{$c1 - $u}{$c2 + $l} = $t{0*(($c1, $c2, $u, $l) = (7 - shift @_, shift @_, ($_ == $m+1) ? ($l, $u) : ($u, $l)))+$c1}{$c2} = 1 for (1.. 2 * $m);
print place($l, $u, -5, -5), $win ? " WIN\n" : "\n";
sub place { my ($u, $l, $c3, $c4, $c5, $c6, $d, $a, $c1, $c2) = (@_,()x($t{$c3}{$c4} = $t{$c5}{$c6} = 1));
for $c1 (1..6) { for $c2 (1..6) { next if (($c1-$u < 1) or ($c2+$l > 6) or $t{$c1}{$c2} or $t{$c1 - $u}{$c2 + $l});
$win = 1 if (++$a and !$d and !place($l, $u, $c1, $c2, $c1-$u, $c2+$l, 1)); } }
return (($t{$c3}{$c4} = $t{$c5}{$c6} = 0) * 0 + $a); }