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.0.0 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.55 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.54 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.53 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.52 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.51 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.50 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.49 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.48 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.47 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.46 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.45 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.44 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.43 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.42 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.41 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.40 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.39 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.38 tracks/perl6/exercises/luhn/example.yaml
trackler-2.1.0.37 tracks/perl6/exercises/luhn/example.yaml