Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] HT Lesson #3 - Converting Roman numerals (continued)

From: gmassar::dreamsoft::com at: 30-Oct-2000 12:53

Geo's Helping Tutorials Motto: Better learning by helping others Basic Programming in REBOL Lesson #3 - Converting Roman numerals (continued) We need to verify our scripts we wrote for Lesson #2, complete free of bug as possible. Let's do it. Make your script turned into "module" as roman.r and write a testing script to verify the logic. Use the table below for your reference. 0 1 2 3 4 5 6 7 8 9 <--- index first-digits: [ none I II III IV V VI VII VIII IX ] second-digits: [ none X XX XXX XL L LX LXX LXXX XC ] third-digits: [ none C CC CCC CD D DC DCC DCCC CM ] fouth-digits: [ none M MM MMM ] To generate every possible Roman numberal, use REBOL loops to concatenate those "elements" in the table. Convert each numeral and compare the result with given evaluation below: legal-value: (1000 * fourth) + (100 * third) + (10 * second) + first where first, second, third and fourth are the indices. Examples: fourth third second first legal-value ------ ----- ------ ----- ----------- XIV --> none none X IV --> 1 4 MMMCDV --> MMM CD none V --> 3 4 0 5 MIM --> M none none none --> illegal There are 3'999 possible combinations to test. Report if the comparison fails. BONUS: Determine the elapsed time to complete the 3'999 tests. SUBMISSION: Post your testing script on REBOL_New list at eGroups.com on Nov. 3rd (Friday) or later. Written testing program in Turbo Pascal 3 will be available upon request. Geo... Helping Tutorials mentor