aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2023-02-27 13:03:34 +0000
committerGitHub <noreply@github.com>2023-02-27 13:03:34 +0000
commitcff557456764cd477196d8c2abcdfedf4aed55a3 (patch)
treef37d9382c79c13ece51b3f98e27f33f4166fe855
parent59ec5a557f0b6a2a8b369d165cd0b30d9fa017d0 (diff)
downloadperlweeklychallenge-club-cff557456764cd477196d8c2abcdfedf4aed55a3.tar.gz
perlweeklychallenge-club-cff557456764cd477196d8c2abcdfedf4aed55a3.tar.bz2
perlweeklychallenge-club-cff557456764cd477196d8c2abcdfedf4aed55a3.zip
Create ch-2.pl
-rw-r--r--challenge-206/james-smith/perl/ch-2.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-206/james-smith/perl/ch-2.pl b/challenge-206/james-smith/perl/ch-2.pl
new file mode 100644
index 0000000000..cd44540577
--- /dev/null
+++ b/challenge-206/james-smith/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use feature qw(say);
+use Test::More;
+
+my @TESTS = (
+ [ [1,2,3,4], 4 ],
+ [ [0,2,1,3], 2 ],
+);
+
+is( max_sum_pair_min( @{$_->[0]} ), $_->[1] ) for @TESTS;
+
+sub max_sum_pair_min {
+ my $t = 0, @_ = sort {$a<=>$b} @_;
+ $t += shift, shift while @_;
+ $t
+}