aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-080/jaldhar-h-vyas/blog.txt1
-rwxr-xr-xchallenge-080/jaldhar-h-vyas/perl/ch-1.pl19
-rwxr-xr-xchallenge-080/jaldhar-h-vyas/perl/ch-2.pl21
-rwxr-xr-xchallenge-080/jaldhar-h-vyas/raku/ch-1.p617
-rwxr-xr-xchallenge-080/jaldhar-h-vyas/raku/ch-2.p617
5 files changed, 75 insertions, 0 deletions
diff --git a/challenge-080/jaldhar-h-vyas/blog.txt b/challenge-080/jaldhar-h-vyas/blog.txt
new file mode 100644
index 0000000000..52704ebc85
--- /dev/null
+++ b/challenge-080/jaldhar-h-vyas/blog.txt
@@ -0,0 +1 @@
+https://www.braincells.com/perl/2020/10/perl_weekly_challenge_week_80.html
diff --git a/challenge-080/jaldhar-h-vyas/perl/ch-1.pl b/challenge-080/jaldhar-h-vyas/perl/ch-1.pl
new file mode 100755
index 0000000000..66eccab233
--- /dev/null
+++ b/challenge-080/jaldhar-h-vyas/perl/ch-1.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use 5.020;
+use warnings;
+
+my @N = @ARGV;
+
+my @positives = sort grep { $_ >= 0; } @N;
+my $smallest = $positives[0];
+
+for my $i (1 .. scalar @positives) {
+ if (($positives[$i] // 'inf') - $smallest > 1) {
+ $smallest++;
+ last;
+ } else {
+ $smallest = $positives[$i];
+ }
+}
+
+say $smallest;
diff --git a/challenge-080/jaldhar-h-vyas/perl/ch-2.pl b/challenge-080/jaldhar-h-vyas/perl/ch-2.pl
new file mode 100755
index 0000000000..92a97da600
--- /dev/null
+++ b/challenge-080/jaldhar-h-vyas/perl/ch-2.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+use 5.020;
+use warnings;
+
+my @N = @ARGV;
+my @candies = map{ 1; } @N;
+
+for my $i (0 .. scalar @N - 1) {
+ if ($N[$i] > ($N[$i - 1] // 'inf')) {
+ $candies[$i]++;
+ }
+ if ($N[$i] > ($N[$i + 1] // 'inf')) {
+ $candies[$i]++;
+ }
+}
+
+my $total = 0;
+foreach (@candies) {
+ $total += $_;
+}
+say $total;
diff --git a/challenge-080/jaldhar-h-vyas/raku/ch-1.p6 b/challenge-080/jaldhar-h-vyas/raku/ch-1.p6
new file mode 100755
index 0000000000..34b7f0a7c6
--- /dev/null
+++ b/challenge-080/jaldhar-h-vyas/raku/ch-1.p6
@@ -0,0 +1,17 @@
+#!/usr/bin/perl6
+
+sub MAIN(
+ *@N #= a list of integers
+) {
+ my @positives = @N.grep({ $_ >= 0}).sort;
+ my $smallest = @positives[0];
+ for 1 .. @positives.elems -> $i {
+ if (@positives[$i] // Inf) - $smallest > 1 {
+ $smallest++;
+ last;
+ } else {
+ $smallest = @positives[$i];
+ }
+ }
+ say $smallest;
+} \ No newline at end of file
diff --git a/challenge-080/jaldhar-h-vyas/raku/ch-2.p6 b/challenge-080/jaldhar-h-vyas/raku/ch-2.p6
new file mode 100755
index 0000000000..e1ba029c27
--- /dev/null
+++ b/challenge-080/jaldhar-h-vyas/raku/ch-2.p6
@@ -0,0 +1,17 @@
+#!/usr/bin/perl6
+
+sub MAIN(
+ *@N #= a list of integers
+) {
+ my @candies = 1 xx @N.elems;
+
+ for 0 ..^ @N.elems -> $i {
+ if @N[$i] > (@N[$i - 1] // Inf) {
+ @candies[$i]++;
+ }
+ if @N[$i] > (@N[$i + 1] // Inf) {
+ @candies[$i]++;
+ }
+ }
+ say [+] @candies;
+} \ No newline at end of file