From 153ff9e564f243e75f33c8352f9b11c85c1e024d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 18 May 2009 21:24:05 -0500 Subject: solution to 32 --- 032.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 032.pl 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; -- cgit v1.2.3