From 279975c1fd05b2455b017a49521e34c64623b05e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 19 May 2009 21:43:30 -0500 Subject: solution for 43 --- 043.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 043.pl diff --git a/043.pl b/043.pl new file mode 100755 index 0000000..1d5607b --- /dev/null +++ b/043.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Math::Combinatorics; +use integer; + +my $comb = Math::Combinatorics->new(data => [0..9]); +my @numbers; +while (my @perm = $comb->next_permutation) { + next unless (100 * $perm[1] + 10 * $perm[2] + $perm[3]) % 2 == 0; + next unless (100 * $perm[2] + 10 * $perm[3] + $perm[4]) % 3 == 0; + next unless (100 * $perm[3] + 10 * $perm[4] + $perm[5]) % 5 == 0; + next unless (100 * $perm[4] + 10 * $perm[5] + $perm[6]) % 7 == 0; + next unless (100 * $perm[5] + 10 * $perm[6] + $perm[7]) % 11 == 0; + next unless (100 * $perm[6] + 10 * $perm[7] + $perm[8]) % 13 == 0; + next unless (100 * $perm[7] + 10 * $perm[8] + $perm[9]) % 17 == 0; + push @numbers, join '', @perm; +} +my $sum = join '+', @numbers; +print qx{echo $sum | bc}; -- cgit v1.2.3