From: Gregory Seidman Date: 2007-01-03T21:45:43+09:00 Subject: Re: Calculating roman numerals On Wed, Jan 03, 2007 at 06:35:02AM +0900, Shiloh Madsen wrote: } Ok, I'm having trouble with another exercise in this book. It has } asked me to write a program that will calculate the old school roman } numeral value for a given modern number (up to the thousands). To } clarify, old school roman numerals didn't do the subtraction thing, so } 4 is IIII, nine is VIIII, etc. I've played around with a few options } using division, loops and modulus, but can't seem to get my brain } around the problem...any suggestions? We recently had a golfing competition at work on going the other direction (i.e. roman numeral to arabic). Our best solution: def x s p=t=0 s.scan(/./){|r| i=' IVXLCDM'.index r c=10**(i/2)/(2-i%2) t+= p