From 3e70da35ee173955ed9990e5dfd214eb8f693e61 Mon Sep 17 00:00:00 2001 From: Andinus Date: Fri, 3 Sep 2021 18:19:01 +0530 Subject: Raku: Luhn: Add solution --- raku/luhn/Luhn.rakumod | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'raku') diff --git a/raku/luhn/Luhn.rakumod b/raku/luhn/Luhn.rakumod index 4b704b5..8efafc0 100644 --- a/raku/luhn/Luhn.rakumod +++ b/raku/luhn/Luhn.rakumod @@ -1,4 +1,11 @@ unit module Luhn; -sub is-luhn-valid(Str $input is copy --> Bool) is export { +sub is-luhn-valid($input is copy --> Bool) is export { + return False if $input.comb.grep(/\d|\s/).join ne $input; + $input = $input.comb.grep(/\d/)>>.Int; + return False if $input.elems < 2; + + ([+] gather for $input.reverse.kv -> $k, $v { + take $k !%% 2 ?? ($_ > 9 ?? $_ - 9 !! $_) !! $v with $v * 2; + }) %% 10; } -- cgit 1.4.1-2-gfad0 master' selected='selected'>master mirror of ranger - a simple, vim-like file managerakspecs <akspecs@tilde.institute>
about summary refs log blame commit diff stats
path: root/tests/manpage_completion_test.py
blob: b9504d06ff26421798690f6851e953abbf6c2cde (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13