summaryrefslogtreecommitdiffstats
path: root/032.pl
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-18 21:24:05 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-18 21:24:05 -0500
commit153ff9e564f243e75f33c8352f9b11c85c1e024d (patch)
treefb3fbf0786eb4f9d3ffb5b8e46a550848fc13094 /032.pl
parent43600492cfedd694a3575dad3ec8d8e65c694474 (diff)
downloadprojecteuler-153ff9e564f243e75f33c8352f9b11c85c1e024d.tar.gz
projecteuler-153ff9e564f243e75f33c8352f9b11c85c1e024d.zip
solution to 32
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;