[CHALLENGE] Boggle

Simon Cozens simon at simon-cozens.org
Wed Jan 29 03:57:28 CST 2003


Well, here's my submission; should be straightforward:

my at n=(0,[0,[[2,2],[2,1],[1,2]],[[2,3],[2,2],[2,1],[1,3]
,[1,1]],[[2,4],[2,3],[2,2],[1,4],[1,2]],[[2,4],[2,3],[1
,3]]],[0,[[3,2],[3,1],[2,2],[1,2],[1,1],[1,2]],[[3,3],[
3,2],[3,1],[2,3],[2,1],[1,3],[1,2],[1,3]],[[3,4],[3,3],
[3,2],[2,4],[2,2],[1,4],[1,3],[1,2]],[[3,4],[3,3],[2,3]
,[1,4]]],[0,[[4,2],[4,1],[3,2],[2,2],[2,1],[2,2]],[[4,3
],[4,2],[4,1],[3,3],[3,1],[2,3],[2,2],[2,3]],[[4,4],[4,
3],[4,2],[3,4],[3,2],[2,4],[2,3],[2,4]],[[4,4],[4,3],[3
,3],[2,4]]],[0,[[4,2],[3,2],[3,1],[3,2]],[[4,3],[4,1],[
3,3],[3,2],[3,3]],[[4,4],[4,2],[3,4],[3,3],[3,4]],[[4,3
],[3,4]]]);my at b=[];my($h,%w);for my $l(0,1,2,3){chop(my
$r=<>);my at r=split//,$r;push at b,[0, at r];push@{$w{$r[$_]}},
[$l,$_]for 1..4;$h.=$r}while (<>){/^[$h]{3,9}$/o||next;
chomp;my at s=split//,(my$w=$_);p($_,{$_->[0].$_->[1]=>1},
@s)&&print$w."\n"for@{$w{shift at s}}}sub p{my($p,$h, at l)=@
_;my at z=@{$n[$p->[0]][$p->[1]]};for my$n(@{$w{shift at l}})
{next if(!scalar grep{$n->[0]==$_->[0]&&$n->[1]==$_->[1
]}@z)||$h->{$n->[0].$n->[1]}++;return!@l||p($n,$h, at l)}}

-- 
Going to church does not make a person religious, nor does going to school
make a person educated, any more than going to a garage makes a person a car.



More information about the Belfast-pm mailing list