From 8b5ddb5b448e5c7d49dedd725bf299da00032bec Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 17 Nov 2012 11:38:31 -0600 Subject: another solution --- CONV.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 CONV.pl diff --git a/CONV.pl b/CONV.pl new file mode 100644 index 0000000..8e9c6a1 --- /dev/null +++ b/CONV.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.016; + +my @s1 = map { int($_ * 1000000) } split ' ', <>; +my @s2 = map { int($_ * 1000000) } split ' ', <>; + +my %totals; +for my $s1 (@s1) { + for my $s2 (@s2) { + say "$s1 $s2" if $s1 - $s2 < 8600000 && $s1 - $s2 > 8500000; + $totals{$s1 - $s2}++; + } +} + +my %convolution = reverse %totals; +my $max = (sort { $a <=> $b } keys %convolution)[-1]; +say $max; +say abs($convolution{$max}) / 1000000; -- cgit v1.2.3