User Control Panel
Advertisements

HELP US, HELP YOU!

Roman Conversion

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Services
View unanswered posts
Author Message
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Sat Dec 18, 2004 12:51 pm    Post subject: Reply with quote

This service converts arabic numbers (1 - 3,999) to roman numerals and vice-versa from i to mmmcmxcix.

To use the service go to: http://plazmabot.com/cgi-bin/service.cgi?service=roman&amm=

Replace with a number or a roman numeral.

Hope you like Smile
Back to top
purcelly
God Like
God Like


Joined: 10 Jun 2004
Posts: 560
Location: North West, England
Reputation: 35.1Reputation: 35.1Reputation: 35.1Reputation: 35.1

PostPosted: Sat Dec 18, 2004 3:03 pm    Post subject: Reply with quote

Nice another good service
Back to top
stof91
Newbie
Newbie


Joined: 29 Sep 2004
Posts: 33

Reputation: 20.2Reputation: 20.2

PostPosted: Sat Dec 18, 2004 4:35 pm    Post subject: Reply with quote

Cool Very Happy

Keep up the good Work Wink
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Sat Dec 18, 2004 5:42 pm    Post subject: Reply with quote

you could save the lwp post and figure the Roman Conversion in your code:


Code:
my $num = 129;<br />my ($one,$ten,$hun) = split(//, reverse $num);<br />my $ret = 'M' x int($num/1000).<br />          (('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM')[$hun]).<br />          (('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC')[$ten]).<br />          (('','I','II','III','*lazy*','V','VI','VII','VIII','IX')[$one]);<br />print $ret;


edit: give me a sec and ill write a reverse

Code:
if($num =~ /^(?: M{0,3})(?: D?C{0,3} | C[DM])(?: L?X{0,3} | X[LC])(?: V?I{0,3} | I[VX])$/ix){<br />    my %roman2arabic = qw(I 1 V 5 X 10 L 50 C 100 D 500 M 1000);<br />    foreach (split(//, uc $num)) {<br />        my($digit) = $roman2arabic{$_};<br />        $ret -= 2 * $last_digit if $last_digit < $digit;<br />        $ret += ($last_digit = $digit);<br />    }<br />print "$ret";<br />}<br />else{<br /> my ($one,$ten,$hun) = split(//, reverse $num);<br /> my $ret = 'M' x int($num/1000).<br />           (('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM')[$hun]).<br />           (('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC')[$ten]).<br />           (('','I','II','III','*lazy*','V','VI','VII','VIII','IX')[$one]);<br /> print "$ret";<br /> }

_________________
[ matt ]
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sat Dec 18, 2004 7:12 pm    Post subject: Reply with quote

I really like services! Razz

But matt's code is pretty cool too.

And finally, there's a Perl module at CPAN and some more for doing the conversion.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Services All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group