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

use strict;
use warnings;
use feature 'say';

NUMBER:
for my $n (100 ... 999) {
  my %product;

  my ($x, $y, $z) = split //, $n;

  $product{$_}++ for ($x, $y, $z, $x * $y, $y * $z, $x * $y * $z);

  # If all of those products are different, then the hash
  # will have exactly six keys
  say "$n is colourful" if keys %product == 6;
}