From 23e8a20883c91a0950db37c8ffa95d775bdef4c0 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Tue, 18 Jul 2023 14:34:53 +0200 Subject: Solution to task 1 --- challenge-226/jo-37/perl/ch-1.pl | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 challenge-226/jo-37/perl/ch-1.pl diff --git a/challenge-226/jo-37/perl/ch-1.pl b/challenge-226/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..c640d81766 --- /dev/null +++ b/challenge-226/jo-37/perl/ch-1.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die < $_[$b]} 0 .. $#_]; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is shuffle_string('lacelengh', 3,2,0,5,4,8,6,7,1), + 'challenge', 'example 1'; + is shuffle_string('rulepark', 4,7,3,1,0,5,2,6), + 'perlraku', 'example 2'; + } + + SKIP: { + skip "tests" unless $tests; + + is shuffle_string('rayadverb', 13, 3, 17, 11, 1, 5, 7, 15, 9), + 'davebarry', 'non-indices'; + is shuffle_string('baab', 2, 1, 1, 2), 'aabb', 'non-unique'; + } + + done_testing; + exit; +} -- cgit From 03d66b78fd33f9484d2fd161f2130b69fffd4d0d Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Tue, 18 Jul 2023 14:35:04 +0200 Subject: Solution to task 2 --- challenge-226/jo-37/perl/ch-2.pl | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 challenge-226/jo-37/perl/ch-2.pl diff --git a/challenge-226/jo-37/perl/ch-2.pl b/challenge-226/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..8a621bd7ff --- /dev/null +++ b/challenge-226/jo-37/perl/ch-2.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <@{@_} = (); + scalar grep $_, keys %v; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is zero_array(1, 5, 0, 3, 5), 3, 'example 1'; + is zero_array(0), 0, 'example 2'; + is zero_array(2, 1, 4, 0, 3), 4, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + + is zero_array(1, 2, 1, 2), 2, 'no zero'; + } + + done_testing; + exit; +} -- cgit