diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-11-17 11:38:31 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-11-17 11:38:31 -0600 |
commit | 8b5ddb5b448e5c7d49dedd725bf299da00032bec (patch) | |
tree | f14995ebcd6b8d5ad15271c09e93819b9e4326ca | |
parent | 3fc0ef8d9e271ebc5e34e28972d4ed646833623a (diff) | |
download | rosalind-8b5ddb5b448e5c7d49dedd725bf299da00032bec.tar.gz rosalind-8b5ddb5b448e5c7d49dedd725bf299da00032bec.zip |
another solution
-rw-r--r-- | CONV.pl | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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; |