From a51f5637cacfedcc699c6783f6d0a7de8c0f2c2e Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:31:07 +0200 Subject: Solution to task 1 --- challenge-284/jo-37/perl/ch-1.pl | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 challenge-284/jo-37/perl/ch-1.pl diff --git a/challenge-284/jo-37/perl/ch-1.pl b/challenge-284/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..ceab3d9239 --- /dev/null +++ b/challenge-284/jo-37/perl/ch-1.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0 '!float'; +use PDL '2.017'; +use PDL::NiceSlice; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <qsort; + my $lucky = $val->where($freq == $val); + $lucky->isempty ? -1 : $lucky(-1;-); +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is lucky_integer(2, 2, 3, 4), 2, 'example 1'; + is lucky_integer(1, 2, 2, 3, 3, 3), 3, 'example 2'; + is lucky_integer(1, 1, 1, 3), -1, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + + is lucky_integer( + qw(11 1 11 2 11 2 11 3 11 3 11 3 11 4 11 4 11 4 11 4 11)), 11, + 'these go to eleven'; + } + + done_testing; + exit; +} -- cgit