aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-051/mohammad-anwar/perl/ch-2.pl3
1 files changed, 3 insertions, 0 deletions
diff --git a/challenge-051/mohammad-anwar/perl/ch-2.pl b/challenge-051/mohammad-anwar/perl/ch-2.pl
index 63a1d81da1..7b32e37aa7 100644
--- a/challenge-051/mohammad-anwar/perl/ch-2.pl
+++ b/challenge-051/mohammad-anwar/perl/ch-2.pl
@@ -7,6 +7,9 @@ use List::Util 1.45 qw(uniq);
foreach my $i (100 .. 999) {
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"