Code Golf: Roman to Decimal
FEB
07
2007
Here is my submission for the Roman to Deciman challenge. Code size: 121 bytes.
v={'I',1,'V',5,'X',10,'L',50,'C',?d,'D',500,'M',1000}
y=q=0
gets.chop.split('').each{|n|j=v[n]
y+=j-(q<j ?q*2:0)
q=j}
p y
Leave a comment:
Popular Posts
Search
Tags
actionmailer activerecord ajax apache apple barcamp caching capistrano centos code golf css db delete eager loading ebay email attachment erb flash ftp fun generators get haml helpers ie sucks javascript jquery lightbox lost merb net ftp paperclip passenger php plexus post presentation rails rails machine railsconf redesign rest rjs routes rss ruby ruby on rails safari script sinatra symfony text replacement tips tutorial twitter xhtml
Projects
© 2010 Travis Roberts. All rights reserved.