diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2022-11-14 13:17:19 +0100 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2022-11-14 13:17:19 +0100 |
| commit | 8c54539653446bb5cfda62610026588b84997a85 (patch) | |
| tree | 5295f792a812a347335d371afb8f46138d681164 | |
| parent | 10c2c4cd953d4f37cd614a0e876f411e13d34ed0 (diff) | |
| download | perlweeklychallenge-club-8c54539653446bb5cfda62610026588b84997a85.tar.gz perlweeklychallenge-club-8c54539653446bb5cfda62610026588b84997a85.tar.bz2 perlweeklychallenge-club-8c54539653446bb5cfda62610026588b84997a85.zip | |
Task 2 added another missing requirement
| -rw-r--r-- | challenge-191/luca-ferrari/postgresql/ch-2.plperl | 11 | ||||
| -rw-r--r-- | challenge-191/luca-ferrari/raku/ch-2.p6 | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/challenge-191/luca-ferrari/postgresql/ch-2.plperl b/challenge-191/luca-ferrari/postgresql/ch-2.plperl index 65186d9c40..98cfcd741b 100644 --- a/challenge-191/luca-ferrari/postgresql/ch-2.plperl +++ b/challenge-191/luca-ferrari/postgresql/ch-2.plperl @@ -26,6 +26,17 @@ AS $CODE$ } $cute_counter++ if ( $is_cute ); + + $is_cute = 1; + for my $i ( 0 .. $current_list->@* ) { + + if ( ( $i + 1 ) % $current_list->[ $i ] != 0 ) { + $is_cute = 0; + last; + } + } + + $cute_counter++ if ( $is_cute ); } return $cute_counter; diff --git a/challenge-191/luca-ferrari/raku/ch-2.p6 b/challenge-191/luca-ferrari/raku/ch-2.p6 index 5090ffa7e6..4d5ad6e09a 100644 --- a/challenge-191/luca-ferrari/raku/ch-2.p6 +++ b/challenge-191/luca-ferrari/raku/ch-2.p6 @@ -12,6 +12,14 @@ sub MAIN( Int $n where { 0 < $n <= 15 } ) { } $cute-counter++ if $is-cute; + + $is-cute = True; + for 0 ..^ $current-list.elems -> $i { + $is-cute = False and last if ( $i + 1 ) !%% $current-list[ $i ] ; + } + + $cute-counter++ if $is-cute; + } $cute-counter.say; } |
