Created
February 9, 2012 03:51
-
-
Save anonymous/1777135 to your computer and use it in GitHub Desktop.
I believe I'm trying to access double arrays wrong. The code is not functional but I believe the logic is sound. Any advice?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $range = 20; | |
my $minimum = 10; | |
my $random_number = (int(rand($range)) + $minimum); | |
my @array1 =([0..$random_number],[0..$random_number]); | |
my @array2 =([0..$random_number],[0..$random_number]); | |
my @solution =([0..$random_number], [0..$random_number]); | |
for(my $index1 = 0; $index1 < $random_number; $index1++){ | |
for(my $index2 = 0; $index2 < $random_number; $index2++){ | |
for(my $index3 = 0; $index3 < $random_number; $index3++){ | |
@solution([$index1],[$index2]) += (@array1([$index1],[$index3]) * @array2([$index3],[$index2])); | |
} | |
} | |
} | |
for(my $index = 0; $index < $random_number; $index++){ | |
for(my $nextIndex = 0; $nextIndex < $random_number; $nextIndex++){ | |
say (@solution([$index],[$nextIndex])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment