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

 Si fueris Romae (Posted on 2010-02-12)
It is a tricky cryptarithm, but still solvable.

I've solved it, why don't you?

ROME-SUM=RUSE

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: I know the trick (spoiler) -- computer solution added | Comment 2 of 5 |
(In reply to I know the trick (spoiler) by Steve Herman)

Each set below is listed in order of

`ROMESUMRUSE`

with the arabic decimal representation on the right:

`DCVI           606XLV            45DLXI           561`
`DCVI           606LXV            65DXLI           541`
`MCVI           1106XLV            45MLXI           1061`
`MCVI           1106LXV            65MXLI           1041`

DECLARE FUNCTION roman\$ (n!)
CLS
FOR a = 10 TO 2000
FOR b = 10 TO a
ar\$ = roman\$(a)
br\$ = roman\$(b)
cr\$ = roman\$(a - b)

IF LEN(ar\$) = 4 AND LEN(br\$) = 3 AND LEN(cr\$) = 4 THEN
IF LEFT\$(ar\$, 1) = LEFT\$(cr\$, 1) THEN
IF MID\$(ar\$, 3, 1) = RIGHT\$(br\$, 1) THEN
IF RIGHT\$(ar\$, 1) = RIGHT\$(cr\$, 1) THEN
IF MID\$(br\$, 2, 1) = MID\$(cr\$, 2, 1) THEN
IF INSTR(MID\$(ar\$, 2), LEFT\$(ar\$, 1)) = 0 THEN
good = 1
FOR i = 1 TO 3
FOR j = 1 TO 4
IF j <> i THEN
IF MID\$(ar\$, i, 1) = MID\$(ar\$, j, 1) THEN good = 0
IF MID\$(br\$, i, 1) = MID\$(br\$, j, 1) THEN good = 0
IF MID\$(cr\$, i, 1) = MID\$(cr\$, j, 1) THEN good = 0
END IF
NEXT
NEXT
IF good THEN
PRINT ar\$, a
PRINT br\$, b
PRINT cr\$, a - b
PRINT
END IF
END IF
END IF
END IF
END IF
END IF
END IF
NEXT
NEXT

FUNCTION roman\$ (n)

q = n \ 1000: r = n MOD 1000
r\$ = STRING\$(q, "M")
n2 = r
q = n2 \ 100: r = n2 MOD 100
SELECT CASE q
CASE 9: r\$ = r\$ + "CM"
CASE 5 TO 8: r\$ = r\$ + "D" + STRING\$(q - 5, "C")
CASE 4: r\$ = r\$ + "CD"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "C")
END SELECT
n2 = r
q = n2 \ 10: r = n2 MOD 10
SELECT CASE q
CASE 9: r\$ = r\$ + "XC"
CASE 5 TO 8: r\$ = r\$ + "L" + STRING\$(q - 5, "X")
CASE 4: r\$ = r\$ + "XL"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "X")
END SELECT
n2 = r
q = n2
SELECT CASE q
CASE 9: r\$ = r\$ + "IX"
CASE 5 TO 8: r\$ = r\$ + "V" + STRING\$(q - 5, "I")
CASE 4: r\$ = r\$ + "IV"
CASE 0 TO 3: r\$ = r\$ + STRING\$(q, "I")
END SELECT

roman\$ = r\$

END FUNCTION

 Posted by Charlie on 2010-02-12 15:45:35

 Search: Search body:
Forums (0)