aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-177/paulo-custodio/perl/ch-2.pl2
-rw-r--r--challenge-179/paulo-custodio/Makefile2
-rw-r--r--challenge-179/paulo-custodio/perl/ch-1.pl38
-rw-r--r--challenge-179/paulo-custodio/perl/ch-2.pl23
-rw-r--r--challenge-179/paulo-custodio/t/test-1.yaml15
-rw-r--r--challenge-179/paulo-custodio/t/test-2.yaml5
6 files changed, 83 insertions, 2 deletions
diff --git a/challenge-177/paulo-custodio/perl/ch-2.pl b/challenge-177/paulo-custodio/perl/ch-2.pl
index a128c71570..2eda7a92c8 100644
--- a/challenge-177/paulo-custodio/perl/ch-2.pl
+++ b/challenge-177/paulo-custodio/perl/ch-2.pl
@@ -62,5 +62,3 @@ sub palindromic_cyclops_prime {
@ARGV==1 or die "usage: ch-2.pl N\n";
my $N = shift;
say join ", ", palindromic_cyclops_prime($N);
-
-
diff --git a/challenge-179/paulo-custodio/Makefile b/challenge-179/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-179/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-179/paulo-custodio/perl/ch-1.pl b/challenge-179/paulo-custodio/perl/ch-1.pl
new file mode 100644
index 0000000000..33f0100618
--- /dev/null
+++ b/challenge-179/paulo-custodio/perl/ch-1.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+# Challenge 179
+#
+# Task 1: Ordinal Number Spelling
+# Submitted by: Mohammad S Anwar
+#
+# You are given a positive number, $n.
+#
+# Write a script to spell the ordinal number.
+#
+# For example,
+#
+# 11 => eleventh
+# 62 => sixty-second
+# 99 => ninety-ninth
+
+use Modern::Perl;
+use Number::Spell;
+
+sub ordinal_number_spelling {
+ my($n) = @_;
+ my $str = spell_number($n);
+ $str =~ s/twelve$/twelfth/ or
+ $str =~ s/one$/first/ or
+ $str =~ s/two$/second/ or
+ $str =~ s/three$/third/ or
+ $str =~ s/four$/forth/ or
+ $str =~ s/five$/fifth/ or
+ $str =~ s/eight$/eighth/ or
+ $str =~ s/nine$/ninth/ or
+ $str =~ s/y$/ieth/ or
+ $str =~ s/$/th/;
+ $str =~ s/ /-/g;
+ return $str;
+}
+
+say ordinal_number_spelling(shift);
diff --git a/challenge-179/paulo-custodio/perl/ch-2.pl b/challenge-179/paulo-custodio/perl/ch-2.pl
new file mode 100644
index 0000000000..ee0470609e
--- /dev/null
+++ b/challenge-179/paulo-custodio/perl/ch-2.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# Challenge 179
+#
+# Task 2: Unicode Sparkline
+# Submitted by: Mohammad S Anwar
+#
+# You are given a list of positive numbers, @n.
+#
+# Write a script to print sparkline in Unicode for the given list of numbers.
+
+use Modern::Perl;
+use List::Util 'max';
+use open qw(:std :utf8);
+
+my @bars = ("\N{U+2581}", "\N{U+2582}", "\N{U+2583}", "\N{U+2584}",
+ "\N{U+2585}", "\N{U+2586}", "\N{U+2587}", "\N{U+2588}");
+
+my @nums = @ARGV;
+my $max = max(@nums);
+my @height = map {int(($_ / $max)*7)} @nums;
+my @chars = @bars[@height];
+say @chars;
diff --git a/challenge-179/paulo-custodio/t/test-1.yaml b/challenge-179/paulo-custodio/t/test-1.yaml
new file mode 100644
index 0000000000..11a1f67837
--- /dev/null
+++ b/challenge-179/paulo-custodio/t/test-1.yaml
@@ -0,0 +1,15 @@
+- setup:
+ cleanup:
+ args: 11
+ input:
+ output: eleventh
+- setup:
+ cleanup:
+ args: 62
+ input:
+ output: sixty-second
+- setup:
+ cleanup:
+ args: 99
+ input:
+ output: ninety-ninth
diff --git a/challenge-179/paulo-custodio/t/test-2.yaml b/challenge-179/paulo-custodio/t/test-2.yaml
new file mode 100644
index 0000000000..a7dbb3251c
--- /dev/null
+++ b/challenge-179/paulo-custodio/t/test-2.yaml
@@ -0,0 +1,5 @@
+- setup:
+ cleanup:
+ args: 0 1 2 3 4 5 6 7 8 9 10
+ input:
+ output: