diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-09-04 23:56:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-04 23:56:02 +0100 |
| commit | 82c7332f9c8dc8c19d1653ef2fa1d140cf920116 (patch) | |
| tree | 776f13637c2ec7a52e5c202354c175b7a2a6fed4 | |
| parent | 5ac3e4ab8f7556098fbf0ec1f86d55adbed2110c (diff) | |
| parent | 1bdf6c9d509c6d1e4a14864179c8036a4f5dd99e (diff) | |
| download | perlweeklychallenge-club-82c7332f9c8dc8c19d1653ef2fa1d140cf920116.tar.gz perlweeklychallenge-club-82c7332f9c8dc8c19d1653ef2fa1d140cf920116.tar.bz2 perlweeklychallenge-club-82c7332f9c8dc8c19d1653ef2fa1d140cf920116.zip | |
Merge pull request #6698 from jaldhar/challenge-180
Challenge 180 by Jaldhar H. Vyas.
| -rw-r--r-- | challenge-180/jaldhar-h-vyas/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-180/jaldhar-h-vyas/perl/ch-1.pl | 18 | ||||
| -rwxr-xr-x | challenge-180/jaldhar-h-vyas/perl/ch-2.pl | 7 | ||||
| -rwxr-xr-x | challenge-180/jaldhar-h-vyas/raku/ch-1.raku | 17 | ||||
| -rwxr-xr-x | challenge-180/jaldhar-h-vyas/raku/ch-2.raku | 8 |
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 |
