Can you find a five-figure number, with distinct digits between 1 and 9, which satisfies
all of the following encoded equations?
BRIAN x 2 = CONGA
LINDA x 3 = NAILER
LEVIK x 4 = VARIED
CORAL x 6 = NESTED
Repeated letters within an equation indicate the replication of digits. However, the same letter in different equations does not necessarily refer to the same digit.
DECLARE FUNCTION checkPat! (a$, b$)
FOR n = 12345 TO 98765
n$ = LTRIM$(STR$(n))
IF checkPat(n$, "brian") THEN
a$ = LTRIM$(STR$(n * 2))
IF checkPat(n$ + a$, "brianconga") THEN
b$ = LTRIM$(STR$(n * 3))
IF checkPat(n$ + b$, "lindanailer") THEN
c$ = LTRIM$(STR$(n * 4))
IF checkPat(n$ + c$, "levikvaried") THEN
d$ = LTRIM$(STR$(n * 6))
IF checkPat(n$ + d$, "coralnested") THEN
PRINT n; "* 2 ="; n * 2
PRINT n; "* 3 ="; n * 3
PRINT n; "* 4 ="; n * 4
PRINT n; "* 6 ="; n * 6
END IF
END IF
END IF
END IF
END IF
NEXT n
FUNCTION checkPat (a$, b$)
d$ = SPACE$(10)
IF LEN(a$) <> LEN(b$) THEN checkPat = 0: EXIT FUNCTION
FOR i = 1 TO LEN(b$)
l$ = MID$(b$, i, 1)
p = VAL(MID$(a$, i, 1)) + 1
IF MID$(d$, p, 1) = " " THEN
IF INSTR(d$, l$) > 0 THEN checkPat = 0: EXIT FUNCTION
MID$(d$, p, 1) = l$
ELSEIF MID$(d$, p, 1) <> l$ THEN
checkPat = 0: EXIT FUNCTION
END IF
NEXT i
checkPat = 1
END FUNCTION
finds
45163 * 2 = 90326
45163 * 3 = 135489
45163 * 4 = 180652
45163 * 6 = 270978
|
Posted by Charlie
on 2006-12-08 11:02:45 |