diff options
| -rw-r--r-- | challenge-235/jaldhar-h-vyas/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-235/jaldhar-h-vyas/perl/ch-1.pl | 18 | ||||
| -rwxr-xr-x | challenge-235/jaldhar-h-vyas/perl/ch-2.pl | 19 | ||||
| -rwxr-xr-x | challenge-235/jaldhar-h-vyas/raku/ch-1.raku | 19 | ||||
| -rwxr-xr-x | challenge-235/jaldhar-h-vyas/raku/ch-2.raku | 21 |
5 files changed, 78 insertions, 0 deletions
diff --git a/challenge-235/jaldhar-h-vyas/blog.txt b/challenge-235/jaldhar-h-vyas/blog.txt new file mode 100644 index 0000000000..3c38917d7f --- /dev/null +++ b/challenge-235/jaldhar-h-vyas/blog.txt @@ -0,0 +1 @@ +https://www.braincells.com/perl/2023/09/perl_weekly_challenge_week_235.html diff --git a/challenge-235/jaldhar-h-vyas/perl/ch-1.pl b/challenge-235/jaldhar-h-vyas/perl/ch-1.pl new file mode 100755 index 0000000000..c7395bdb2d --- /dev/null +++ b/challenge-235/jaldhar-h-vyas/perl/ch-1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use 5.030; +use warnings; +use experimental qw/ smartmatch /; + +my $increasing = undef; + +for my $i (0 .. scalar @ARGV - 1) { + my @copy = @ARGV; + splice @copy, $i, 1; + + if (\@copy ~~ [sort @copy]) { + $increasing = 1; + last; + } +} + +say $increasing ? 'true' : 'false'; diff --git a/challenge-235/jaldhar-h-vyas/perl/ch-2.pl b/challenge-235/jaldhar-h-vyas/perl/ch-2.pl new file mode 100755 index 0000000000..305e099b70 --- /dev/null +++ b/challenge-235/jaldhar-h-vyas/perl/ch-2.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +use 5.030; +use warnings; + +my @output; + +for my $elem (@ARGV) { + if ($elem == 0) { + push @output, 0, 0; + } else { + push @output, $elem; + } + + if (scalar @output == scalar @ARGV) { + last; + } +} + +say q{(}, (join q{, }, @output), q{)};
\ No newline at end of file diff --git a/challenge-235/jaldhar-h-vyas/raku/ch-1.raku b/challenge-235/jaldhar-h-vyas/raku/ch-1.raku new file mode 100755 index 0000000000..94ea8c2355 --- /dev/null +++ b/challenge-235/jaldhar-h-vyas/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/raku + +sub MAIN( + *@ints +) { + my Bool $increasing = False; + + for 0 .. @ints.end -> $i { + my @copy = @ints; + @copy.splice($i, 1); + + if [<] @copy { + $increasing = True; + last; + } + } + + say $increasing; +}
\ No newline at end of file diff --git a/challenge-235/jaldhar-h-vyas/raku/ch-2.raku b/challenge-235/jaldhar-h-vyas/raku/ch-2.raku new file mode 100755 index 0000000000..e8b0250d5d --- /dev/null +++ b/challenge-235/jaldhar-h-vyas/raku/ch-2.raku @@ -0,0 +1,21 @@ +#!/usr/bin/raku + +sub MAIN( + *@ints +) { + my @output; + + for @ints -> $elem { + if $elem == 0 { + @output.push(| (0, 0)); + } else { + @output.push($elem); + } + + if @output.elems == @ints.elems { + last; + } + } + + say q{(}, @output.join(q{, }, ), q{)}; +}
\ No newline at end of file |
