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.13 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.12 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.11 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.10 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.9 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.8 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.7 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.6 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.5 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.4 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.3 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.2 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.1 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.1.0 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.6 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.5 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.4 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.3 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.2 tracks/perl6/exercises/luhn/example.yaml
trackler-2.2.0.1 tracks/perl6/exercises/luhn/example.yaml