summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-11-17 11:38:31 -0600
committerJesse Luehrs <doy@tozt.net>2012-11-17 11:38:31 -0600
commit8b5ddb5b448e5c7d49dedd725bf299da00032bec (patch)
treef14995ebcd6b8d5ad15271c09e93819b9e4326ca
parent3fc0ef8d9e271ebc5e34e28972d4ed646833623a (diff)
downloadrosalind-8b5ddb5b448e5c7d49dedd725bf299da00032bec.tar.gz
rosalind-8b5ddb5b448e5c7d49dedd725bf299da00032bec.zip
another solution
-rw-r--r--CONV.pl20
1 files changed, 20 insertions, 0 deletions
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;