From 09a6c865607f509af50b9e62249babe849cfa538 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:45:27 +0100 Subject: Solution to task 1 --- challenge-251/jo-37/perl/ch-1.pl | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 challenge-251/jo-37/perl/ch-1.pl diff --git a/challenge-251/jo-37/perl/ch-1.pl b/challenge-251/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..11402fc894 --- /dev/null +++ b/challenge-251/jo-37/perl/ch-1.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die < Date: Wed, 10 Jan 2024 21:45:42 +0100 Subject: Solution to task 2 --- challenge-251/jo-37/perl/ch-2.pl | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 challenge-251/jo-37/perl/ch-2.pl diff --git a/challenge-251/jo-37/perl/ch-2.pl b/challenge-251/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..aa771f7f27 --- /dev/null +++ b/challenge-251/jo-37/perl/ch-2.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0 '!float'; +use PDL; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <xchg(0, 1)->maxover->minimum; + $minmax == $m->minover->maximum ? $minmax : -1; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is lucky_number( + [ 3, 7, 8], + [ 9, 11, 13], + [15, 16, 17]), 15, 'example 1'; + + is lucky_number( + [ 1, 10, 4, 2], + [ 9, 3, 8, 7], + [15, 16, 17, 12]), 12, 'example 2'; + + is lucky_number( + [7 ,8], + [1 ,2]), 7, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + + is lucky_number( + [2, 7, 5], + [6, 1, 8], + [3, 9, 4]), -1, 'none'; + + # not unique: + is lucky_number( + [2, 3, 3], + [1, 2, 3], + [1, 1, 2]), 2, 'only one three twos is lucky'; + } + + done_testing; + exit; +} -- cgit From b278047e47d0ec05f940110181bf12a3f5f2e541 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:44:47 +0100 Subject: Blog for challenge 251 --- challenge-251/jo-37/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-251/jo-37/blog.txt diff --git a/challenge-251/jo-37/blog.txt b/challenge-251/jo-37/blog.txt new file mode 100644 index 0000000000..f69aedfe0b --- /dev/null +++ b/challenge-251/jo-37/blog.txt @@ -0,0 +1 @@ +https://github.sommrey.de/blog/pwc/challenge-251 -- cgit