aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-162/luca-ferrari/raku/ch-1.p66
1 files changed, 6 insertions, 0 deletions
diff --git a/challenge-162/luca-ferrari/raku/ch-1.p6 b/challenge-162/luca-ferrari/raku/ch-1.p6
new file mode 100755
index 0000000000..0c4ccef759
--- /dev/null
+++ b/challenge-162/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,6 @@
+#!raku
+
+sub MAIN( Str $isbn where { $isbn.chars == 12 && $isbn.comb.grep( * ~~ / <[0 .. 9]> / ).elems == $isbn.chars } ) {
+ my $position = 0;
+ say 10 - ( $isbn.comb.map( { $_ * ( ++$position %% 2 ?? 3 !! 1 ) } ).sum % 10 );
+}