aboutsummaryrefslogtreecommitdiff
path: root/challenge-179
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-179')
-rwxr-xr-xchallenge-179/e-choroba/perl/ch-1.pl12
-rwxr-xr-xchallenge-179/e-choroba/perl/ch-2.pl19
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-179/e-choroba/perl/ch-1.pl b/challenge-179/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..6b3984faed
--- /dev/null
+++ b/challenge-179/e-choroba/perl/ch-1.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Lingua::EN::Numbers ();
+
+*ordinal_number_spelling = *Lingua::EN::Numbers::num2en_ordinal;
+
+use Test::More tests => 3;
+is ordinal_number_spelling(11), 'eleventh', 'Example 1';
+is ordinal_number_spelling(62), 'sixty-second', 'Example 2';
+is ordinal_number_spelling(99), 'ninety-ninth', 'Example 3';
diff --git a/challenge-179/e-choroba/perl/ch-2.pl b/challenge-179/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..79cae1dbc3
--- /dev/null
+++ b/challenge-179/e-choroba/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use utf8;
+use experimental 'signatures';
+
+use POSIX qw{ round };
+use List::Util qw{ min max };
+
+my @BLOCKS = split //, '▁▂▃▄▅▆▇█';
+sub unicode_sparkline (@n) {
+ my ($min, $max) = (min(@n), max(@n));
+ my $step = ($max - $min) / 7;
+ return join "", @BLOCKS[map round(($_ - $min) / $step), @n]
+}
+
+use Test::More tests => 1;
+
+is unicode_sparkline(map $_ * 2.3, 1 .. 8), '▁▂▃▄▅▆▇█';