diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-18 21:24:05 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-18 21:24:05 -0500 |
commit | 153ff9e564f243e75f33c8352f9b11c85c1e024d (patch) | |
tree | fb3fbf0786eb4f9d3ffb5b8e46a550848fc13094 | |
parent | 43600492cfedd694a3575dad3ec8d8e65c694474 (diff) | |
download | projecteuler-153ff9e564f243e75f33c8352f9b11c85c1e024d.tar.gz projecteuler-153ff9e564f243e75f33c8352f9b11c85c1e024d.zip |
solution to 32
-rwxr-xr-x | 032.pl | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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; |