diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-06-24 22:21:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-24 22:21:04 +0100 |
| commit | d1daa3d60187aa86b6e6d877d2acb65341e263ff (patch) | |
| tree | 59040d9540f0ecc5f00b82211521a013fd90adfa | |
| parent | e706d2548a3ce7ff5d3ae480224ee3ee6c5577de (diff) | |
| parent | 53ad7a4fc2868f0f42d5aa0e0f81c93378733b3f (diff) | |
| download | perlweeklychallenge-club-d1daa3d60187aa86b6e6d877d2acb65341e263ff.tar.gz perlweeklychallenge-club-d1daa3d60187aa86b6e6d877d2acb65341e263ff.tar.bz2 perlweeklychallenge-club-d1daa3d60187aa86b6e6d877d2acb65341e263ff.zip | |
Merge pull request #10310 from jmaslak/joelle-week-275
Joelle Maslak's solutions for week 275
| -rwxr-xr-x | challenge-275/joelle-maslak/perl/ch-1.pl | 14 | ||||
| -rwxr-xr-x | challenge-275/joelle-maslak/perl/ch-2.pl | 18 | ||||
| -rwxr-xr-x | challenge-275/joelle-maslak/raku/ch-1.raku | 6 | ||||
| -rwxr-xr-x | challenge-275/joelle-maslak/raku/ch-2.raku | 15 | ||||
| -rwxr-xr-x | challenge-275/joelle-maslak/test-1.sh | 28 | ||||
| -rwxr-xr-x | challenge-275/joelle-maslak/test-2.sh | 28 |
6 files changed, 109 insertions, 0 deletions
diff --git a/challenge-275/joelle-maslak/perl/ch-1.pl b/challenge-275/joelle-maslak/perl/ch-1.pl new file mode 100755 index 0000000000..390a5febfd --- /dev/null +++ b/challenge-275/joelle-maslak/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use v5.34; +use strict; +use warnings; + +MAIN: { + my $sentence = $ARGV[0]; + my $badkeys = $ARGV[1]; + + my $count = scalar grep {! /[$badkeys]/i} split /\s+/, $sentence; + + say $count; +} diff --git a/challenge-275/joelle-maslak/perl/ch-2.pl b/challenge-275/joelle-maslak/perl/ch-2.pl new file mode 100755 index 0000000000..05eca7c7a5 --- /dev/null +++ b/challenge-275/joelle-maslak/perl/ch-2.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use JTM::Boilerplate 'script'; + +MAIN: { + my $input = $ARGV[0]; + + my $letter = "a"; + for my $current (split //, $input) { + if ($current =~ /^\d$/) { + print chr(ord($letter) + $current); + } else { + print $current; + $letter = $current; + } + } + say ""; +} diff --git a/challenge-275/joelle-maslak/raku/ch-1.raku b/challenge-275/joelle-maslak/raku/ch-1.raku new file mode 100755 index 0000000000..cfae04b31f --- /dev/null +++ b/challenge-275/joelle-maslak/raku/ch-1.raku @@ -0,0 +1,6 @@ +#!/usr/bin/env raku +use v6.d; + +sub MAIN($sentence, $badkeys) { + say $sentence.fc.words.grep({!(.comb ∩ $badkeys.fc.comb)}).elems; +} diff --git a/challenge-275/joelle-maslak/raku/ch-2.raku b/challenge-275/joelle-maslak/raku/ch-2.raku new file mode 100755 index 0000000000..7b4cd75af2 --- /dev/null +++ b/challenge-275/joelle-maslak/raku/ch-2.raku @@ -0,0 +1,15 @@ +#!/usr/bin/env raku +use v6.d; + +sub MAIN($input) { + my $letter = "a"; + for $input.comb() -> $current { + if ($current ~~ /^\d$/) { + print chr(ord($letter) + $current); + } else { + print $current; + $letter = $current; + } + } + say ""; +}
\ No newline at end of file diff --git a/challenge-275/joelle-maslak/test-1.sh b/challenge-275/joelle-maslak/test-1.sh new file mode 100755 index 0000000000..9db4fc0ccc --- /dev/null +++ b/challenge-275/joelle-maslak/test-1.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +test_it() { + echo -n $1 "'$2'" $3 ... + OUT=$($1 "$2" "$3") + if [ "$OUT" == "$4" ] ; then + echo "ok" + else + echo "INCORRECT ($OUT)" + fi +} + +test_combo() { + test_it "$1" "Perl Weekly Challenge" la 0 + test_it "$1" "Perl and Raku" a 1 + test_it "$1" "Well done Team PWC" lo 2 + test_it "$1" "The joys of polyglottism" T 2 +} + +do_it() { + test_combo "perl perl/ch-1.pl" + test_combo "raku raku/ch-1.raku" +} + +do_it "$@" + + diff --git a/challenge-275/joelle-maslak/test-2.sh b/challenge-275/joelle-maslak/test-2.sh new file mode 100755 index 0000000000..8d2d17e201 --- /dev/null +++ b/challenge-275/joelle-maslak/test-2.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +test_it() { + echo -n $1 $2 ... + OUT=$($1 $2) + if [ "$OUT" == "$3" ] ; then + echo "ok" + else + echo "INCORRECT ($OUT)" + fi +} + +test_combo() { + test_it "$1" "a1c1e1" "abcdef" + test_it "$1" "a1b2c3d4" "abbdcfdh" + test_it "$1" "b2b" "bdb" + test_it "$1" "a16z" "abgz" +} + +do_it() { + test_combo "perl perl/ch-2.pl" + test_combo "raku raku/ch-2.raku" +} + +do_it "$@" + + |
