From 359f26f7f293eb1860c52a3b6b0733b542f4ace0 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:02:19 +0100 Subject: Solution to task 1 --- challenge-256/jo-37/perl/ch-1.pl | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 challenge-256/jo-37/perl/ch-1.pl diff --git a/challenge-256/jo-37/perl/ch-1.pl b/challenge-256/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..f1cc4ac2c0 --- /dev/null +++ b/challenge-256/jo-37/perl/ch-1.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <@{@_} = map scalar reverse, @_; + + delete @words{grep $_ eq $words{$_}, keys %words}; + (grep defined, delete @words{values %words}) / 2; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is maximum_pairs("ab", "de", "ed", "bc"), 1, 'example 1'; + is maximum_pairs("aa", "ba", "cd", "ed"), 0, 'example 2'; + is maximum_pairs("uv", "qp", "st", "vu", "mn", "pq"), 2, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + } + + done_testing; + exit; +} -- cgit From 2a5c60ff88208f05606014c2b020a4563086cd04 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:02:30 +0100 Subject: Solution to task 2 --- challenge-256/jo-37/perl/ch-2.pl | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 challenge-256/jo-37/perl/ch-2.pl diff --git a/challenge-256/jo-37/perl/ch-2.pl b/challenge-256/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..e2109afcc2 --- /dev/null +++ b/challenge-256/jo-37/perl/ch-2.pl @@ -0,0 +1,59 @@ +#!/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 < Date: Thu, 15 Feb 2024 21:03:51 +0100 Subject: Blog for challenge 256 --- challenge-256/jo-37/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-256/jo-37/blog.txt diff --git a/challenge-256/jo-37/blog.txt b/challenge-256/jo-37/blog.txt new file mode 100644 index 0000000000..b99574fff2 --- /dev/null +++ b/challenge-256/jo-37/blog.txt @@ -0,0 +1 @@ +https://github.sommrey.de/blog/pwc/challenge-256 -- cgit