All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Roman Trivia (Posted on 2009-05-17) Difficulty: 2 of 5
Take all the Roman numbers (using the modern standard subtractive notation in which IV = 4, IX = 9, XL = 40, XLIX = 49, XC = 90, etc.) from I to M (1 to 1000)...

1. Which number has the most Roman letters?

2. If you group them by the number of Roman letters, which group has the most members?

3. How many numbers start with C?

4. There is something interesting about the groupings in #2. What is it?

See The Solution Submitted by Sing4TheDay    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
answers to 1,2,3 working on 4 | Comment 1 of 7

I used the following Basic code to compile the list by length and show all that start with C.

DECLARE SUB RomanNumerals (num$)
DECLARE SUB RomanReplace (num$, Frm$, R$)
DECLARE FUNCTION Romans$ (n%)
CLS 0
OPEN ".output.txt" FOR OUTPUT AS #1
PRINT #1, "Length", "Decimal Value", "Roman Numeral"
DIM lngcnts%(1 TO 12)
FOR lng% = 1 TO 12
 lngcnts%(lng%) = 0
 FOR num% = 1 TO 1000
  rmn$ = Romans$(num%)
  IF LEN(rmn$) = lng% THEN
   PRINT #1, lng%, num%, rmn$
   lngcnts%(lng%) = lngcnts%(lng%) + 1
  END IF
 NEXT num%
NEXT lng%
PRINT #1, ""
PRINT #1, "Length", "Number of this length"
FOR i% = 1 TO 12
 PRINT #1, i%, lngcnts%(i%)
NEXT i%
PRINT #1, ""
PRINT #1, "Values starting with C"
cnt% = 0
FOR num% = 1 TO 1000
 rmn$ = Romans$(num%)
 IF MID$(rmn$, 1, 1) = "C" THEN
  cnt% = cnt% + 1
  PRINT #1, num%, rmn$
 END IF
NEXT num%
PRINT #1, "There are " + STR$(cnt%) + " numbers starting with C"
CLOSE #1


SUB RomanNumerals (num$)
   x% = VAL(num$): num$ = "": IF x% < 1 THEN EXIT SUB
   DIM Ones(10) AS STRING
   Ones(0) = "": Ones(1) = "I": Ones(2) = "II"
   Ones(3) = "III": Ones(4) = "IV": Ones(5) = "V"
   Ones(6) = "VI": Ones(7) = "VII": Ones(8) = "VIII": Ones(9) = "IX"
   Tens$ = "XLC": Hund$ = "CDM"
   num$ = Ones(x% MOD 10)
   n$ = Ones((x% 10) MOD 10): RomanReplace num$, n$, Tens$
   n$ = Ones((x% 100) MOD 10): RomanReplace num$, n$, Hund$
   num$ = STRING$(x% 1000, "M") + num$
END SUB

SUB RomanReplace (num$, Frm$, R$)
   FOR t% = 1 TO LEN(Frm$)
      MID$(Frm$, t%, 1) = MID$(R$, INSTR("IVX", MID$(Frm$, t%, 1)))
   NEXT: num$ = Frm$ + num$
END SUB

FUNCTION Romans$ (n%)
   t$ = STR$(n%): RomanNumerals t$: Romans$ = t$
END FUNCTION

<output too large for this post will try to put in seperate post>

Edited on May 17, 2009, 5:01 pm

Edited on May 17, 2009, 5:01 pm
  Posted by Daniel on 2009-05-17 14:11:26

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information