From: Paul Smith Date: 2009-11-12T01:12:41+09:00 Subject: Re: Roman Numerals (Arrgh!) On Wed, Nov 11, 2009 at 4:03 PM, Rob Biedenharn wrote: > On Nov 11, 2009, at 10:56 AM, Paul Smith wrote: >> >> On Wed, Nov 11, 2009 at 3:51 PM, Gennady Bystritsky >> wrote: >>> >>> On Nov 11, 2009, at 5:35 AM, Rob Biedenharn wrote: >>> >>>>>> >>>>>> And with an appropriately formed $numerals array, the "subtraction >>>>>> rule" is already covered. ;-) >>>>> >>>>> Would you please elaborate? You mean same algorithm and "better" >>>>> $numerals would cover mapping of 4 => "IV", 9 => "IX", etc.? >>>>> >>>>>> >>>>>> -Rob >>>> >>>> >>>> Yes, that's it exactly. Testing/using 9 before 5, you find IX (and >>>> stop) before you go to VIIII. You can't repeat one of the "subtraction >>>> groups" the way that you can repeat the individual numerals: 8 is >>>> always VIII and never IVIV or IIX >>> >>> Now you intrigued me ;-). So I am asking directly -- given the following >>> $numerals: >>> $numerals = [[1000, "M"], [500, "D"], [100, "C"], [50, "L"], [10, "X"], >>> [5, "V"], [1, "I"]] >> >> $numerals = [[1000, "M"], [900, "CM"], [500, "D"], [400, "CD"], [100, >> "C"], [90, "XC"], [50, "L"], [40, "XL"], [10, "X"], [9, "IX"], [5, >> "V"], [4, "IV"], [1, "I"]] >> >>> >>> ...how one can transform it so that the original algorithm would produced >>> shortened roman numbers? Please present the exact value of $numerals >>> satisfying the above condition. >>> >>> Gennady. >> >> -- >> Paul Smith >> http://www.nomadicfun.co.uk >> >> paul@pollyandpaul.co.uk > > > Oh, sorry.  I meant "What Paul said" > No worries! It is quite beautiful in fact, and very surprising when you haven't thought about it. But, if there are no thousands left to deal with, and you do have a 900 left, there's only one way to represent it. If you have less than 900 remaining, you have to drop to 500 and build up again :) -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk