[SPOLIER] Solution to Perl 'Hard' Quiz of the Week #2005-03-22
Daniel Martin <martin-+m399P62/[email protected]> Mon, 28 Mar 2005 14:45:30 -0500
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
My solution is pretty similar to what's gone before; it only deals
with the stated problem and with odd N:
#!perl
# Look ma, no use of %
sub gen_is_divisible_fsm
{
my $n = shift;
my @s = map { {ret => $_, next_states => [undef, undef]}; }
(0..$n-1);
my @t = (@s,@s);
$t[2*$_ ]{next_states}[0] = $_ for (0..$n-1);
$t[2*$_+1]{next_states}[1] = $_ for (0..$n-1);
return (0, \@s);
}
__END__