From 8c54539653446bb5cfda62610026588b84997a85 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 14 Nov 2022 13:17:19 +0100 Subject: Task 2 added another missing requirement --- challenge-191/luca-ferrari/postgresql/ch-2.plperl | 11 +++++++++++ challenge-191/luca-ferrari/raku/ch-2.p6 | 8 ++++++++ 2 files changed, 19 insertions(+) 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; } -- cgit