aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-180/jaldhar-h-vyas/blog.txt1
-rwxr-xr-xchallenge-180/jaldhar-h-vyas/perl/ch-1.pl18
-rwxr-xr-xchallenge-180/jaldhar-h-vyas/perl/ch-2.pl7
-rwxr-xr-xchallenge-180/jaldhar-h-vyas/raku/ch-1.raku17
-rwxr-xr-xchallenge-180/jaldhar-h-vyas/raku/ch-2.raku8
5 files changed, 51 insertions, 0 deletions
diff --git a/challenge-180/jaldhar-h-vyas/blog.txt b/challenge-180/jaldhar-h-vyas/blog.txt
new file mode 100644
index 0000000000..f09b66c3b9
--- /dev/null
+++ b/challenge-180/jaldhar-h-vyas/blog.txt
@@ -0,0 +1 @@
+https://www.braincells.com/perl/2022/09/perl_weekly_challenge_week_180.html \ No newline at end of file
diff --git a/challenge-180/jaldhar-h-vyas/perl/ch-1.pl b/challenge-180/jaldhar-h-vyas/perl/ch-1.pl
new file mode 100755
index 0000000000..408f2e2394
--- /dev/null
+++ b/challenge-180/jaldhar-h-vyas/perl/ch-1.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+use 5.030;
+use warnings;
+
+my $s = shift // die "need a string in quotation marks\n";
+my %chars;
+
+my $pos = 0;
+for my $c (split //, $s) {
+ if (exists $chars{$c}) {
+ $chars{$c} = "Inf";
+ } else {
+ $chars{$c} = $pos;
+ }
+ $pos++;
+}
+
+say $chars{ (sort { $chars{$a} <=> $chars{$b}} keys %chars)[0] };
diff --git a/challenge-180/jaldhar-h-vyas/perl/ch-2.pl b/challenge-180/jaldhar-h-vyas/perl/ch-2.pl
new file mode 100755
index 0000000000..694ca153e9
--- /dev/null
+++ b/challenge-180/jaldhar-h-vyas/perl/ch-2.pl
@@ -0,0 +1,7 @@
+#!/usr/bin/perl
+use 5.030;
+use warnings;
+
+my ($i, @n) = @ARGV;
+
+say join q{, }, grep { $_ > $i } @n;
diff --git a/challenge-180/jaldhar-h-vyas/raku/ch-1.raku b/challenge-180/jaldhar-h-vyas/raku/ch-1.raku
new file mode 100755
index 0000000000..c88d6784dc
--- /dev/null
+++ b/challenge-180/jaldhar-h-vyas/raku/ch-1.raku
@@ -0,0 +1,17 @@
+#!/usr/bin/raku
+
+sub MAIN(
+ Str $s #= a string in quotation marks
+) {
+ my %chars;
+
+ for $s.comb.antipairs -> $c {
+ if %chars{$c.key}:exists {
+ %chars{$c.key} = ∞;
+ } else {
+ %chars{$c.key} = $c.value;
+ }
+ }
+
+ say (%chars.sort({ $^a.value <=> $^b.value})).first.value;
+} \ No newline at end of file
diff --git a/challenge-180/jaldhar-h-vyas/raku/ch-2.raku b/challenge-180/jaldhar-h-vyas/raku/ch-2.raku
new file mode 100755
index 0000000000..685596b16e
--- /dev/null
+++ b/challenge-180/jaldhar-h-vyas/raku/ch-2.raku
@@ -0,0 +1,8 @@
+#!/usr/bin/raku
+
+sub MAIN(
+ $i, #= a number to use as a filter
+ *@n #= a list of numbers to trim
+) {
+ @n.grep({ $_ > $i}).join(q{, }).say;
+} \ No newline at end of file