aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-141/james-smith/perl/ch-1.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/challenge-141/james-smith/perl/ch-1.pl b/challenge-141/james-smith/perl/ch-1.pl
new file mode 100644
index 0000000000..69282db686
--- /dev/null
+++ b/challenge-141/james-smith/perl/ch-1.pl
@@ -0,0 +1,32 @@
+#!/usr/local/bin/perl
+
+use strict;
+
+use warnings;
+use feature qw(say);
+use Test::More;
+use Benchmark qw(cmpthese timethis);
+use Data::Dumper qw(Dumper);
+
+my @primes = (2,3,5,7,11,13);
+my @vals;
+
+##
+## We know that all such numbers must have the form:
+## p^3.q, p.q.r
+## where p, q, r are all primes...
+##
+## We therefore constuct all such combinations of the primes <= 13
+## this should include the 10 numbers we are looking for!
+
+while(@primes) {
+ my $p1 = shift @primes;
+ my @t = @primes;
+ while( @t ) {
+ my $p2 = shift @t;
+ push @vals, $p1*$p2*$p2*$p2, $p2*$p1*$p1*$p1, map {$p1*$p2*$_} @t;
+ }
+}
+
+say join "\n",(sort{$a<=>$b}@vals)[0..9];
+