Sha256: ee2a81b951b7e5de5c0079929691a7ba7a342b8ec96473c7d6e507012a67a46d
Contents?: true
Size: 581 Bytes
Versions: 82
Compression:
Stored size: 581 Bytes
Contents
exercise: Luhn version: 1 plan: 15 imports: '&is-luhn-valid' tests: | is .<input>.&is-luhn-valid, |.<expected description> for @($c-data<cases>); unit: module example: | sub is-luhn-valid ($input is copy) is export { $input ~~ s:g/\s+//; return False if $input.chars < 2 || $input ~~ /\D/; my @num = $input.split('', :skip-empty); @num.unshift: 0 if @num % 2; my $sum; for @num -> $a, $b { $sum += $a * 2; $sum -= 9 if $a * 2 > 9; $sum += $b; } return ($sum %% 10).so; } stub: | sub is-luhn-valid ($input) is export { }
Version data entries
82 entries across 82 versions & 1 rubygems