aboutsummaryrefslogtreecommitdiff
path: root/challenge-051/mohammad-anwar/perl/ch-1.pl
blob: e9c00dbf4e5a216a00eddedfe7a23d19d8f53563 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

use strict;
use warnings;

my @L = (-25, -10, -7, -3, 2, 4, 8, 10);
my $S = $#L;
my $T = 0;

foreach my $i (0 .. $S) {
    foreach my $j (0 .. $S) {
        next if ($i == $j);
        foreach my $k (0 .. $S) {
            next if (($k == $i) || ($k == $j));
            print sprintf("[%d, %d, %d]\n", $L[$i], $L[$j], $L[$k])
                if ($L[$i] + $L[$j] + $L[$k] == $T);
        }
    }
}