From 2e2fbc3ca44c1e1de1fcfc86172a16f484c3747c Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Mon, 29 Mar 2021 22:45:00 +0200 Subject: Solution to task 1 --- challenge-106/jo-37/perl/ch-1.pl | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 challenge-106/jo-37/perl/ch-1.pl (limited to 'challenge-106') diff --git a/challenge-106/jo-37/perl/ch-1.pl b/challenge-106/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..ab6c9dc6bb --- /dev/null +++ b/challenge-106/jo-37/perl/ch-1.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl -s + +use v5.16; +use Test2::V0; +use List::Util qw(min max); + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die < $l; + $a <=> $b} @_; + + (max values %gap) // 0; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + is max_gap(2, 9, 3, 5), 4, 'example 1'; + is max_gap(1, 3, 8, 2, 0), 5, 'example 2'; + is max_gap(5), 0, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + is max_gap(1, -1, -2, -3, 3, 2, 1, -1), 2, 'non-unique values'; + is max_gap(0, 0, 0), 0, 'constant value'; + is max_gap(2, 5), 3, 'pair'; + } + + done_testing; + exit; +} -- cgit