The following program fails to find a solution. The program itself tries to produce all possible results and place them in a file with the result at the beginning of each record. That file is sorted and then another program looks for matches with three different equations producing them.
I had written a program for pluribus 1, but due to a bug (not permuting the numbers) did not find the answer. This program could have some other bug, or the answer is more exotic than allowed for here:
DEFDBL A-Z
op$ = "+-*/^"
DATA 3,5,18, 10,13,36, 24,27,29
FOR i = 1 TO 3
FOR j = 1 TO 3
READ opnd(i, j)
NEXT
NEXT
OPEN "epluribs.txt" FOR OUTPUT AS #2
FOR eq = 1 TO 3
DO
FOR op1 = 1 TO 5
err1 = 0
SELECT CASE op1
CASE 1
rslt1a = opnd(eq, 1) + opnd(eq, 2)
CASE 2
rslt1a = opnd(eq, 1) - opnd(eq, 2)
CASE 3
rslt1a = opnd(eq, 1) * opnd(eq, 2)
CASE 4
rslt1a = opnd(eq, 1) / opnd(eq, 2)
CASE 5
IF LOG(opnd(eq, 1)) * opnd(eq, 2) < 300 * LOG(10) THEN
rslt1a = opnd(eq, 1) ^ opnd(eq, 2)
ELSE
rslt1a = 1: err1 = 1
END IF
END SELECT
IF err1 = 0 THEN
FOR op2 = 1 TO 5
err1 = 0
err2 = 0
SELECT CASE op2
CASE 1
rslt2a = opnd(eq, 2) + opnd(eq, 3)
rslt1 = rslt1a + opnd(eq, 3)
CASE 2
rslt2a = opnd(eq, 2) - opnd(eq, 3)
rslt1 = rslt1a - opnd(eq, 3)
CASE 3
rslt2a = opnd(eq, 2) * opnd(eq, 3)
rslt1 = rslt1a * opnd(eq, 3)
CASE 4
rslt2a = opnd(eq, 2) / opnd(eq, 3)
rslt1 = rslt1a / opnd(eq, 3)
CASE 5
IF LOG(opnd(eq, 2)) * opnd(eq, 3) < 300 * LOG(10) THEN
rslt2a = opnd(eq, 2) ^ opnd(eq, 3)
ELSE
rslt2a = 1: err2 = 1
END IF
IF LOG(ABS(rslt1a)) * opnd(eq, 3) < 300 * LOG(10) THEN
rslt1 = rslt1a ^ opnd(eq, 3)
ELSE
rslt1 = 0: err1 = 1
END IF
END SELECT
SELECT CASE op1
CASE 1
rslt2 = opnd(eq, 1) + rslt2a
CASE 2
rslt2 = opnd(eq, 1) - rslt2a
CASE 3
rslt2 = opnd(eq, 1) * rslt2a
CASE 4
rslt2 = opnd(eq, 1) / rslt2a
CASE 5
IF LOG(opnd(eq, 1)) * rslt2a < 300 * LOG(10) THEN
rslt2 = opnd(eq, 1) ^ rslt2a
ELSE
rslt2 = 1: err2 = 1
END IF
END SELECT
IF err1 = 0 THEN
PRINT #2, rslt1; TAB(30);
PRINT #2, USING "## "; eq;
PRINT #2, USING " # ## ! ## ! ##"; 1; opnd(eq, 1); MID$(op$, op1); opnd(eq, 2); MID$(op$, op2); opnd(eq, 3)
END IF
IF err2 = 0 THEN
PRINT #2, rslt2; TAB(30);
PRINT #2, USING "## "; eq;
PRINT #2, USING " # ## ! ## ! ##"; 2; opnd(eq, 1); MID$(op$, op1); opnd(eq, 2); MID$(op$, op2); opnd(eq, 3)
END IF
NEXT
END IF
NEXT op1
flag = 0
IF opnd(eq, 1) < opnd(eq, 2) THEN
IF opnd(eq, 2) < opnd(eq, 3) THEN
SWAP opnd(eq, 2), opnd(eq, 3)
ELSE
IF opnd(eq, 3) < opnd(eq, 1) THEN
h = opnd(eq, 1)
opnd(eq, 1) = opnd(eq, 2)
opnd(eq, 2) = opnd(eq, 3)
opnd(eq, 3) = h
ELSE
h = opnd(eq, 3)
opnd(eq, 3) = opnd(eq, 2)
opnd(eq, 2) = opnd(eq, 1)
opnd(eq, 1) = h
END IF
END IF
ELSE
IF opnd(eq, 2) < opnd(eq, 3) THEN
SWAP opnd(eq, 2), opnd(eq, 3)
ELSE
SWAP opnd(eq, 1), opnd(eq, 3): flag = 1
END IF
END IF
PRINT opnd(eq, 1), opnd(eq, 2), opnd(eq, 3)
LOOP UNTIL flag
NEXT eq
|
Posted by Charlie
on 2004-01-22 11:21:33 |