Skip to content

Instantly share code, notes, and snippets.

Created May 1, 2013 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5497871 to your computer and use it in GitHub Desktop.
Save anonymous/5497871 to your computer and use it in GitHub Desktop.
masakism ROMAN
use Test;
is to_roman(3), "III", "3 gets converted to III";
sub to_roman (Int $n is copy) {
my $printstring;
for <M 1000 D 500 C 100 L 50 X 10 V 5 I 1> -> $roman, $decimal {
$printstring ~= $roman x $n div +$decimal;
$n %= $decimal;
}
for <DCCCC CM CCCC CD LXXXX XC XXXX XL VIIII IX IIII IV> -> $long, $short {
$printstring ~~ s:g/$long/$short/;
}
say $printstring;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment