DECLARE SUB permute (a$)
CLS
a$ = "1234567890": h$ = a$
DO
IF INSTR(a$, "0") > 2 THEN
w = VAL(MID$(a$, 1, 1))
a = VAL(MID$(a$, 2, 1))
o = VAL(MID$(a$, 3, 1))
r = VAL(MID$(a$, 4, 1))
d = VAL(MID$(a$, 5, 1))
s = VAL(MID$(a$, 6, 1))
c = VAL(MID$(a$, 7, 1))
t = VAL(MID$(a$, 8, 1))
i = VAL(MID$(a$, 9, 1))
n = VAL(MID$(a$, 10, 1))
words = 10000 * w + 1000 * o + 100 * r + 10 * d + s
war = 100 * w + 10 * a + r
actions = 1000000 * a + 100000 * c + 10000 * t + 1000 * i + 100 * o + 10 * n + s
IF words * war = actions THEN
PRINT w; a; o; r; d; s; c; t; i; n
PRINT "w; a; o; r; d; s; c; t; i; n"
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
SUB permute (a$)
DEFINT A-Z
x$ = ""
FOR i = LEN(a$) TO 1 STEP -1
l$ = x$
x$ = MID$(a$, i, 1)
IF x$ < l$ THEN EXIT FOR
NEXT
IF i = 0 THEN
FOR j = 1 TO LEN(a$) \ 2
x$ = MID$(a$, j, 1)
MID$(a$, j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
MID$(a$, LEN(a$) - j + 1, 1) = x$
NEXT
ELSE
FOR j = LEN(a$) TO i + 1 STEP -1
IF MID$(a$, j, 1) > x$ THEN EXIT FOR
NEXT
MID$(a$, i, 1) = MID$(a$, j, 1)
MID$(a$, j, 1) = x$
FOR j = 1 TO (LEN(a$) - i) \ 2
x$ = MID$(a$, i + j, 1)
MID$(a$, i + j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
MID$(a$, LEN(a$) - j + 1, 1) = x$
NEXT
END IF
END SUB
finds the correspondence:
2 5 3 4 7 0 9 6 1 8
w; a; o; r; d; s; c; t; i; n
Then, filling in with short missing words, we get:
(the) wounds (from) words (are) worse (than) (the) wounds (from) sword.
|
Posted by Charlie
on 2014-01-09 18:47:47 |