summaryrefslogtreecommitdiffstats
path: root/032.pl
diff options
context:
space:
mode:
Diffstat (limited to '032.pl')
-rwxr-xr-x032.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/032.pl b/032.pl
new file mode 100755
index 0000000..63e3104
--- /dev/null
+++ b/032.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use 5.010;
+use List::Util qw/sum/;
+
+my %found;
+
+A: for my $a (1..99) {
+ B: for my $b ($a..9999) {
+ my $prod = $a * $b;
+ my $length = length($prod) + length($a) + length($b);
+ next B if $length < 9;
+ next A if $length > 9;
+ $found{$prod} = 1
+ if join('', sort split //, "$a$b$prod") eq '123456789';
+ }
+}
+say sum keys %found;