aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shitov <mail@andreyshitov.com>2025-10-20 11:04:33 +0200
committerAndrew Shitov <mail@andreyshitov.com>2025-10-20 11:04:33 +0200
commit3379d2813af3034df641c244e04e72472c713681 (patch)
treeed1a98c78062682432a8bbe197cf5a42c47059c7
parent18f46ea22406f141268e80c4803185a3e14c0830 (diff)
downloadperlweeklychallenge-club-3379d2813af3034df641c244e04e72472c713681.tar.gz
perlweeklychallenge-club-3379d2813af3034df641c244e04e72472c713681.tar.bz2
perlweeklychallenge-club-3379d2813af3034df641c244e04e72472c713681.zip
Task 2 Week 344 in Raku by @ash
-rw-r--r--challenge-344/ash/raku/ch-2.raku12
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-344/ash/raku/ch-2.raku b/challenge-344/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..6e192376b8
--- /dev/null
+++ b/challenge-344/ash/raku/ch-2.raku
@@ -0,0 +1,12 @@
+# Task 2 of the Weekly Challenge 344
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-344/#TASK2
+
+say can-form-array(([2,3], [1], [4]), (1, 2, 3, 4)); # True
+say can-form-array(([1,3], [2,4]), (1, 2, 3, 4)); # False
+say can-form-array(([9,1], [5,8], [2]), (5, 8, 2, 9, 1)); # True
+say can-form-array(([1], [3]), (1, 2, 3)); # False
+say can-form-array(([7,4,6]), (7, 4, 6)); # True
+
+sub can-form-array(@source, @target) {
+ @target ~~ any(@source.permutations>>.flat)
+}