DECLARE SUB permute (a$)
CLS
a$ = "1234567890": h$ = a$
DO
IF INSTR(a$, "0") > 3 THEN
g = VAL(MID$(a$, 1, 1))
b = VAL(MID$(a$, 2, 1))
e = VAL(MID$(a$, 3, 1))
a = VAL(MID$(a$, 4, 1))
d = VAL(MID$(a$, 5, 1))
t = VAL(MID$(a$, 6, 1))
u = VAL(MID$(a$, 7, 1))
x = VAL(MID$(a$, 8, 1))
r = VAL(MID$(a$, 9, 1))
s = VAL(MID$(a$, 10, 1))
gadget = 100100 * g + 10000 * a + 1000 * d + 10 * e + t
budget = 100000 * b + 10000 * u + 1000 * d + 100 * g + 10 * e + t
extras = 100000 * e + 10000 * x + 1000 * t + 100 * r + 10 * a + s
IF gadget + budget = extras THEN
PRINT " gadget budget extras"
PRINT gadget; budget; extras
END IF
END IF
permute a$
LOOP UNTIL a$ = h$
finds
gadget budget extras
386392 516392 902784
taxes are a bad *dea, but *ust ex*st
John Muir was born in Dunbar, East Lothian, Scotland, according to Wikipedia.
Taxes are a bad idea, but just (must?) exist.
|
Posted by Charlie
on 2014-01-23 17:19:20 |