Use of uninitialized value in multiplication (*) at CM.pl line 45.
Use of uninitialized value in numeric eq (==) at CM.pl line 62.
Use of uninitialized value in numeric eq (==) at CM.pl line 62.
Use of uninitialized value in numeric eq (==) at CM.pl line 62.
Use of uninitialized value in string at CM.pl line 85.
Use of uninitialized value in string at CM.pl line 85.
Use of uninitialized value in string at CM.pl line 85.
Go here for code with lines: http://pastebin.com/m340892c3
#!/usr/bin/perl -w
#CM.pl
sub doMath;
sub checkDeath;
sub checkPossible;
sub checkDuplicate;
sub testCheck;
sub depthFirst;
sub breadthFirst;
sub popPrint;
my @Stack;
my @root = qw(0 0 1);
push @Stack, @root;
depthFirst(\@Stack, \@root);
sub doMath
{
my ($node, $choice) = @_;
print "$_" for @{$node};
if($choice == '1')
{
$node[0] += $node[2];
}
elsif($choice == '2')
{
$node[1] += $node[2];
}
elsif($choice == '3')
{
$node[0] += $node[2]*2;
}
elsif($choice == '4')
{
$node[1] += $node[2]*2;
}
elsif($choice == '5')
{
$node[1] += $node[2];
$node[0] += $node[2];
}
$node[2] *= -1;
}
sub checkDeath
{
my ($node) = @_;
my @DeathStates = qw(3 2 3 1 2 1 0 1 0 2 1 2);
# 0 1
# 0 3 2
# 1 3 1
# 2 2 1
# 3 0 1
# 4 0 2
# 5 1 2
my $size = (scalar @DeathStates)/2;
for ($x = 0, $x < $size, $x++)
{
if($node[1] == pop @DeathStates && $node[0] == pop @DeathStates)
{
return 0;
}
}
return 1;
}
sub checkPossible
{
return 1;
}
sub checkDuplicate
{
my ($Stack, $node) = @_;
$size = (scalar @Stack)/3;
@StackNode = (pop@Stack, pop@Stack, pop@Stack);
@StackNode = reverse @StackNode;
for (my $x = 0, $x < $size, $x++)
{
if ( "$node[0]" eq "$StackNode[0]"
&& "$node[1]" eq "$StackNode[1]"
&& "$node[2]" eq "$StackNode[2]")
{
return 0;
}
}
return 1;
}
sub testCheck
{
my ($Stack, $array) = @_;
checkPossible (@array);
checkDeath (@array);
checkDuplicate (\@Stack, \@array);
}
sub depthFirst
{
my ($Stack, $node) = @_;
my $choice = 1;
doMath(\@node, \$choice);
$check = testCheck(@Stack, @node);
if ($check == 1)
{
push @Stack, @node;
}
elsif ($check == 0)
{
foreach $spot (@node)
{
print $spot;
}
print ": Not Valid";
}
else
{
print "Some random problem has happened.";
}
}
sub breadthFirst
{
}
sub shiftPrint
{
my ($Stack) = @_;
my @node = (shift @Stack, shift @Stack, shift @Stack);
foreach $spot (@node)
{
print $spot;
}
}
sub popPrint
{
my ($Stack) = @_;
# print @Stack;
# print "\n";
my @node = (pop @Stack, pop @Stack, pop @Stack);
foreach $spot (@node)
{
print $spot;
}
}
This post has been edited by joshthejest: 01 March 2008 - 05:33 PM

New Topic/Question
Reply



MultiQuote



|