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

Version Path
trackler-2.2.1.33 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.32 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.31 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.30 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.29 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.28 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.27 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.26 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.25 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.24 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.23 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.22 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.21 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.20 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.19 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.18 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.17 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.16 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.15 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.14 tracks/perl6/exercises/luhn/example.yaml