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.53 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.52 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.51 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.50 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.49 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.48 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.47 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.46 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.45 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.44 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.43 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.42 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.41 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.40 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.39 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.38 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.37 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.36 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.35 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.34 tracks/perl6/exercises/luhn/example.yaml