-
-
Save nicokaiser/3946228 to your computer and use it in GitHub Desktop.
Conversion from Roman to Arabic numerals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$_=shift@ARGV;s/Mↂ/+9000/g;s/Mↁ/+4000/g;s/CM/+900/g;s/CD/+400/g;s/XC/+90/g;s/XL/+40/g;s/IX/+9/g;s/IV/+4/g;s/ↂ/+10000/g;s/ↁ/+5000/g;s/M/+1000/g;s/D/+500/g;s/C/+100/g;s/L/+50/g;s/X/+10/g;s/V/+5/g;s/I/+1/g;/^[0-9\+]*$/ or die;eval'print 0'.$_; |
Even shorter version without error handling and support for 10.000 ("ↂ") and 5.000 ("ↁ"): https://gist.github.com/3946249
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage: ./r.pl MCMLXXXI