aboutsummaryrefslogtreecommitdiff
path: root/challenge-235
diff options
context:
space:
mode:
authorJaldhar H. Vyas <jaldhar@braincells.com>2023-09-19 16:23:49 -0400
committerJaldhar H. Vyas <jaldhar@braincells.com>2023-09-21 10:27:25 -0400
commita4ba9a795c98a676f04673f893f6502abbc98e9a (patch)
treeaa6bfacc2ad51c1f643a12b62c590ca7345d5d92 /challenge-235
parentaee701524950403dce06a2a835452b79eacabce1 (diff)
downloadperlweeklychallenge-club-a4ba9a795c98a676f04673f893f6502abbc98e9a.tar.gz
perlweeklychallenge-club-a4ba9a795c98a676f04673f893f6502abbc98e9a.tar.bz2
perlweeklychallenge-club-a4ba9a795c98a676f04673f893f6502abbc98e9a.zip
Challenge 235 by Jaldhar H. Vyas.
Diffstat (limited to 'challenge-235')
-rw-r--r--challenge-235/jaldhar-h-vyas/blog.txt1
-rwxr-xr-xchallenge-235/jaldhar-h-vyas/perl/ch-1.pl18
-rwxr-xr-xchallenge-235/jaldhar-h-vyas/perl/ch-2.pl19
-rwxr-xr-xchallenge-235/jaldhar-h-vyas/raku/ch-1.raku19
-rwxr-xr-xchallenge-235/jaldhar-h-vyas/raku/ch-2.raku21
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