Can you find one five figure number, with distinct digits between 1 and 9, which satisfies all four of the following equations?
SNAKE * 2 = MERES
COYPU * 8 = POODLE
TIGER * 13 = BEWAIL
OKAPI * 14 = HIJACK
Repeated letters within an equation refer to the same digit. The same letter appearing in different equations does not necessarily refer to the same digit.
The puzzle can be solved from just two equations. The other two are for fun/reference.
This is similar to Can't see the wood for the trees
(In reply to
re: Well, if you only rely on two ... (computer solution; spoiler) by Josie Faulkner)
You are right. My program only checked in one direction to be sure that a given digit is represented by only one letter, but not whether a given letter represents only one digit. The corrected program finds only one solution regardless of what pair of equations you choose.
DECLARE FUNCTION ok! (s1$, s2$)
CLS
FOR n1 = 1 TO 4
taken(n1) = 1
FOR n2 = 0 TO 9
IF taken(n2) = 0 THEN
taken(n2) = 1
FOR n3 = 0 TO 9
IF taken(n3) = 0 THEN
taken(n3) = 1
FOR n4 = 0 TO 9
IF taken(n4) = 0 THEN
taken(n4) = 1
FOR n5 = 0 TO 9
IF taken(n5) = 0 THEN
taken(n5) = 1
n = 10000 * n1 + 1000 * n2 + 100 * n3 + 10 * n4 + n5
nt1$ = LTRIM$(STR$(n))
nt2$ = LTRIM$(STR$(n * 2))
nt3$ = LTRIM$(STR$(n * 8))
nt4$ = LTRIM$(STR$(n * 13))
nt5$ = LTRIM$(STR$(n * 14))
IF ok(nt1$ + nt2$, "snakemeres") THEN t1 = 1: ELSE t1 = 0
IF ok(nt1$ + nt3$, "coypupoodle") THEN t2 = 1: ELSE t2 = 0
IF ok(nt1$ + nt4$, "tigerbewail") THEN t3 = 1: ELSE t3 = 0
IF ok(nt1$ + nt5$, "okapihijack") THEN t4 = 1: ELSE t4 = 0
IF t1 + t2 + t3 + t4 >= 2 THEN
PRINT : PRINT t1; t2; t3; t4
PRINT n
IF t1 THEN PRINT nt2$: ELSE PRINT "not fit"
IF t2 THEN PRINT nt3$: ELSE PRINT "not fit"
IF t3 THEN PRINT nt4$: ELSE PRINT "not fit"
IF t4 THEN PRINT nt5$: ELSE PRINT "not fit"
END IF
'END IF
'END IF
'END IF
'END IF
taken(n5) = 0
END IF
NEXT
taken(n4) = 0
END IF
NEXT
taken(n3) = 0
END IF
NEXT
taken(n2) = 0
END IF
NEXT
taken(n1) = 0
NEXT
FUNCTION ok (s1$, s2$)
IF LEN(s2$) <> LEN(s1$) THEN ok = 0: EXIT FUNCTION
chk$ = SPACE$(LEN(s1$))
FOR i = 1 TO LEN(s1$)
c1$ = MID$(s1$, i, 1): c2$ = MID$(s2$, i, 1)
ix = INSTR(s1$, c1$)
IF ix < i THEN
IF MID$(chk$, ix, 1) <> c2$ THEN ok = 0: EXIT FUNCTION
END IF
MID$(chk$, i, 1) = c2$
NEXT
chk$ = SPACE$(LEN(s1$))
FOR i = 1 TO LEN(s1$)
c1$ = MID$(s1$, i, 1): c2$ = MID$(s2$, i, 1)
ix = INSTR(s2$, c2$)
IF ix < i THEN
IF MID$(chk$, ix, 1) <> c1$ THEN ok = 0: EXIT FUNCTION
END IF
MID$(chk$, i, 1) = c1$
NEXT
ok = 1
END FUNCTION
Newly added code in bold.

Posted by Charlie
on 20080321 21:57:26 