aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-255/paulo-custodio/Makefile2
-rw-r--r--challenge-255/paulo-custodio/perl/ch-1.pl28
-rw-r--r--challenge-255/paulo-custodio/perl/ch-2.pl36
-rw-r--r--challenge-255/paulo-custodio/t/test-1.yaml15
-rw-r--r--challenge-255/paulo-custodio/t/test-2.yaml10
5 files changed, 91 insertions, 0 deletions
diff --git a/challenge-255/paulo-custodio/Makefile b/challenge-255/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-255/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-255/paulo-custodio/perl/ch-1.pl b/challenge-255/paulo-custodio/perl/ch-1.pl
new file mode 100644
index 0000000000..edf0c5bb5e
--- /dev/null
+++ b/challenge-255/paulo-custodio/perl/ch-1.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+# Challenge 255
+#
+# Task 1: Odd Character
+# Submitted by: Mohammad Sajid Anwar
+# You are given two strings, $s and $t. The string $t is generated using the
+# shuffled characters of the string $s with an additional character.
+#
+# Write a script to find the additional character in the string $t..
+#
+# Example 1
+# Input: $s = "Perl" $t = "Preel"
+# Output: "e"
+# Example 2
+# Input: $s = "Weekly" $t = "Weeakly"
+# Output: "a"
+# Example 3
+# Input: $s = "Box" $t = "Boxy"
+# Output: "y"
+
+use Modern::Perl;
+
+my($word, $shuffled) = @ARGV;
+for my $ch (split //, $word) {
+ $shuffled =~ s/$ch//i;
+}
+say $shuffled;
diff --git a/challenge-255/paulo-custodio/perl/ch-2.pl b/challenge-255/paulo-custodio/perl/ch-2.pl
new file mode 100644
index 0000000000..5f123273fd
--- /dev/null
+++ b/challenge-255/paulo-custodio/perl/ch-2.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+
+# Challenge 255
+#
+# Task 2: Most Frequent Word
+# Submitted by: Mohammad Sajid Anwar
+# You are given a paragraph $p and a banned word $w.
+#
+# Write a script to return the most frequent word that is not banned.
+#
+# Example 1
+# Input: $p = "Joe hit a ball, the hit ball flew far after it was hit."
+# $w = "hit"
+# Output: "ball"
+#
+# The banned word "hit" occurs 3 times.
+# The other word "ball" occurs 2 times.
+# Example 2
+# Input: $p = "Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge."
+# $w = "the"
+# Output: "Perl"
+#
+# The banned word "the" occurs 3 times.
+# The other word "Perl" occurs 2 times.
+
+use Modern::Perl;
+
+my($banned, @paragraph) = @ARGV;
+my %count;
+my @words =
+ map { $_->[0] }
+ sort { $b->[1] <=> $a->[1] }
+ map { [$_, $count{$_}++] }
+ grep { lc($banned) ne lc($_) }
+ split /\W/, "@paragraph";
+say $words[0];
diff --git a/challenge-255/paulo-custodio/t/test-1.yaml b/challenge-255/paulo-custodio/t/test-1.yaml
new file mode 100644
index 0000000000..86c04b3e79
--- /dev/null
+++ b/challenge-255/paulo-custodio/t/test-1.yaml
@@ -0,0 +1,15 @@
+- setup:
+ cleanup:
+ args: Perl Preel
+ input:
+ output: e
+- setup:
+ cleanup:
+ args: Weekly Weeakly
+ input:
+ output: a
+- setup:
+ cleanup:
+ args: Box Boxy
+ input:
+ output: y
diff --git a/challenge-255/paulo-custodio/t/test-2.yaml b/challenge-255/paulo-custodio/t/test-2.yaml
new file mode 100644
index 0000000000..fb73e3f567
--- /dev/null
+++ b/challenge-255/paulo-custodio/t/test-2.yaml
@@ -0,0 +1,10 @@
+- setup:
+ cleanup:
+ args: hit Joe hit a ball, the hit ball flew far after it was hit.
+ input:
+ output: ball
+- setup:
+ cleanup:
+ args: the Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.
+ input:
+ output: Perl