From dd95a52513c3e127588be0a077347ad8cd9f9882 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Sun, 30 Apr 2023 21:20:03 +0200 Subject: Challenge 145 task 1 --- challenge-145/jo-37/perl/ch-1.pl | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 challenge-145/jo-37/perl/ch-1.pl diff --git a/challenge-145/jo-37/perl/ch-1.pl b/challenge-145/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..220093fa67 --- /dev/null +++ b/challenge-145/jo-37/perl/ch-1.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0 '!float'; +use PDL; +use experimental 'signatures'; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <dummy(0))->sclr; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is dot_product([1, 2, 3], [4, 5, 6]), 32, 'example'; + } + + SKIP: { + skip "tests" unless $tests; + } + + done_testing; + exit; +} -- cgit From 360dd21eeecc7276b8fa0c6dd7dc4412fe3eeb96 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:16:29 +0200 Subject: Challenge 146 task 2 --- challenge-146/jo-37/perl/ch-2.pl | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 challenge-146/jo-37/perl/ch-2.pl diff --git a/challenge-146/jo-37/perl/ch-2.pl b/challenge-146/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..aedafe7fdd --- /dev/null +++ b/challenge-146/jo-37/perl/ch-2.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; +use experimental 'signatures'; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <@*); + local $, = ' '; + say map {join '/', @$_} @parents; +} + + +### Implementation + +# The child nodes are made from the parent's +# - numerator and numerator + denominator +# - numerator + denominator and denominator +# In reverse, the parent depends on the order of the child's denominator +# and numerator and may be reconstructed easily. +sub curious_parent ($d, $n) { + $d < $n ? [$d, $n - $d] : [$d - $n, $n]; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + my $parent = curious_parent(3, 5); + is $parent, [3, 2], 'example 1 parent'; + is curious_parent(@$parent), [1, 2], 'example 1 grandparent'; + + $parent = curious_parent(4, 3); + is $parent, [1, 3], 'example 2 parent'; + is curious_parent(@$parent), [1, 2], 'example 2 grandparent'; + } + + SKIP: { + skip "tests" unless $tests; + } + + done_testing; + exit; +} -- cgit From 24fbfdf83065251a1280a215b98ee37703c0c9a0 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Mon, 1 May 2023 17:13:09 +0200 Subject: Challenge 147 task 1 --- challenge-147/jo-37/perl/ch-1.pl | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 challenge-147/jo-37/perl/ch-1.pl diff --git a/challenge-147/jo-37/perl/ch-1.pl b/challenge-147/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..bef3fd8a26 --- /dev/null +++ b/challenge-147/jo-37/perl/ch-1.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; +use warnings FATAL => 'all'; +use Math::Prime::Util qw(fromdigits todigits is_prime); +use Data::Dump qw(dd pp); +use experimental 'signatures'; + +our ($tests, $examples, $base); +$base ||= 10; + +run_tests() if $tests || $examples; # does not return + +die <