From 895a9d76deaaebf7e0d63a3e2551b0c1fb1bcd11 Mon Sep 17 00:00:00 2001 From: k-mx Date: Mon, 26 Apr 2021 00:31:12 +0500 Subject: Challenge 109 part 2 by Maxim Kolodyazhny My first Raku solution :3 --- challenge-109/maxim-kolodyazhny/raku/ch-2.raku | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 challenge-109/maxim-kolodyazhny/raku/ch-2.raku diff --git a/challenge-109/maxim-kolodyazhny/raku/ch-2.raku b/challenge-109/maxim-kolodyazhny/raku/ch-2.raku new file mode 100755 index 0000000000..bc524a2fef --- /dev/null +++ b/challenge-109/maxim-kolodyazhny/raku/ch-2.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +multi sub MAIN ( $_ where { /\,/ } ) { samewith .split: <,> } +multi sub MAIN ( $_ where { .unique and .all ~~ /^ \d+ $/ and .elems == 7 }) { + .permutations + .first({ + [==] .rotor( <2 -1 3 -1 3 -1>.pairup )>>.sum + }) + .say +} + +sub USAGE() { + print qq:to/EOH/; + Usage: {$*PROGRAM-NAME} [1,2,3...,7] + + Prints the answer for "Four Squares Puzzle" +EOH +} + -- cgit