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

use strict;
use warnings;

use List::Util 1.45 qw(uniq);

foreach my $i (234 .. 987) {
    my @N = split //, $i;
    # Only try if all three digits are unique.
    next if ( scalar(uniq(@N)) != scalar(@N) );

    my @S = ($N[0], $N[1], $N[2], ($N[0] * $N[1]), ($N[1] * $N[2]), ($N[0] * $N[1] * $N[2]));

    print "[$i] => [", join(", ", @S), "]\n"
        if ( scalar(uniq(@S)) == scalar(@S) );
}