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
... then don't rely on just the first two or the first and last. Any other pair will lead to a solution, but those two pairs won't.
The first line of each grouping below shows, for lines 1 through 4, whether the equation can be made to fit with the five-figure number on line 2: a 1 for yes, and a 2 for no. The remaining lines show the right-hand side for each of the four lines, if possible.
1 1 0 0
48137
96274
385096
not fit
not fit
1 1 0 0
48512
97024
388096
not fit
not fit
1 0 0 1
48517
97034
not fit
not fit
679238
1 1 1 1
48537
97074
388296
630981
679518
1 1 0 0
48615
97230
388920
not fit
not fit
Only 48537 fits all four, or the four pairs of equations from which it can be solved (1 and 3, 2 and 3, 2 and 4 or 3 and 4).
The program is only a slight modification of one I had written for Can't see the wood for the trees (not the one shown in comments there, which was to extend possible multiples and words).
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
ok = 1
END FUNCTION
|
Posted by Charlie
on 2008-03-21 12:24:40 |