Created
August 23, 2012 13:36
-
-
Save ichirin2501/3436660 to your computer and use it in GitHub Desktop.
Project Euler 32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use List::Util qw/sum/; | |
my %S = (); | |
for(my $i=1000; $i<=9999; $i++){ | |
for(my $j=1; $j*$j<=$i; $j++){ | |
if( $i % $j == 0 ){ | |
my $k = $i / $j; | |
my %h; | |
@h{(split(//,$i),split(//,$j),split(//,$k))} = (); | |
if( !exists($h{0}) && scalar(keys %h) == 9 ){ | |
$S{$i} = 1; | |
} | |
} | |
} | |
} | |
print sum(keys %S),"\n"; | |
# => 45228 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment