From 5afab29454b75fa55cc54fc32fa39b20aea75134 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 15 May 2009 10:01:55 -0500 Subject: add my slow solution to 29, and my broken attempt at a faster one --- 029-slow.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 029-slow.pl (limited to '029-slow.pl') diff --git a/029-slow.pl b/029-slow.pl new file mode 100755 index 0000000..8f36b00 --- /dev/null +++ b/029-slow.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings; +use 5.010; +use List::MoreUtils qw/uniq/; + +my $n = $ARGV[0]; + +my @list; +my %list; +for my $a (2..$n) { + for my $b (2..$n) { + my $pow = `echo '$a^$b' | bc`; + chomp $pow; + #push @{ $list{$pow} ||= [] }, [$a, $b]; + push @list, $pow; + } + #say $a; +} +#for my $val (keys %list) { + #next unless @{ $list{$val} } > 1; + #say join ' == ', map { "$_->[0]^$_->[1]" } @{ $list{$val} }; +#} +say scalar uniq sort @list; -- cgit v1.2.3-54-g00ecf