aboutsummaryrefslogtreecommitdiff
path: root/challenge-010/e-choroba
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2020-02-12 18:09:17 +0100
committerE. Choroba <choroba@matfyz.cz>2020-02-12 18:12:40 +0100
commita844652adbb1d20822baa6ae61073f2940714425 (patch)
tree893da2ab5295be6a643bc182d941f89f826bffc8 /challenge-010/e-choroba
parent192fc28eb8de4065a07582b2a19f04f35ffd0da6 (diff)
downloadperlweeklychallenge-club-a844652adbb1d20822baa6ae61073f2940714425.tar.gz
perlweeklychallenge-club-a844652adbb1d20822baa6ae61073f2940714425.tar.bz2
perlweeklychallenge-club-a844652adbb1d20822baa6ae61073f2940714425.zip
Solve 047 (Roman Calculator and Gapful Number) by E. Choroba
Code to handle Roman Numberals extracted from 010.
Diffstat (limited to 'challenge-010/e-choroba')
-rwxr-xr-xchallenge-010/e-choroba/perl5/ch-1a.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-010/e-choroba/perl5/ch-1a.pl b/challenge-010/e-choroba/perl5/ch-1a.pl
new file mode 100755
index 0000000000..9f64ce21b5
--- /dev/null
+++ b/challenge-010/e-choroba/perl5/ch-1a.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use lib '../../../challenge-047/e-choroba/perl';
+use MyRoman qw{ to_roman from_roman };
+
+use Test::More;
+
+my %test = (XXXIX => 39,
+ CCXLVI => 246,
+ DCCLXXXIX => 789,
+ MMCDXXI => 2421,
+ CLX => 160,
+ CCVII => 207,
+ MIX => 1009,
+ MLXVI => 1066,
+ MDCCLXXVI => 1776,
+ MCMIII => 1903, # MDCDIII
+ MCMX => 1910,
+ MCMLIV => 1954,
+ MCMXCIX => 1999, # MIM
+ MMXIX => 2019,
+ MMMCMXCIX => 3_999);
+
+for my $roman (keys %test) {
+ is from_roman($roman), $test{$roman};
+}
+
+for my $roman (keys %test) {
+ is to_roman($test{$roman}), $roman;
+}
+
+is from_roman('MIM'), 1999;
+is from_roman('MDCDIII'), 1903;
+
+done_testing();