472918365
563819274
are the only two results and are therefore the lowest and highest by default.
DECLARE SUB permute (a$)
CLS
a$ = "123456789": h$ = a$
DO
a = INSTR(a$, "1")
b = INSTR(a$, "2")
c = INSTR(a$, "3")
d = INSTR(a$, "4")
e = INSTR(a$, "5")
tot2 = 0
tot3 = 0
tot4 = 0
tot5 = 0
FOR i = a TO b STEP SGN(b  a): tot2 = tot2 + VAL(MID$(a$, i, 1)): NEXT
IF tot2 = 12 THEN
FOR i = b TO c STEP SGN(c  b): tot3 = tot3 + VAL(MID$(a$, i, 1)): NEXT
IF tot3 = 23 THEN
FOR i = c TO d STEP SGN(d  c): tot4 = tot4 + VAL(MID$(a$, i, 1)): NEXT
IF tot4 = 34 THEN
FOR i = d TO e STEP SGN(e  d): tot5 = tot5 + VAL(MID$(a$, i, 1)): NEXT
IF tot5 = 45 THEN
PRINT a$
END IF
END IF
END IF
END IF
permute a$
LOOP UNTIL a$ = h$

Posted by Charlie
on 20101021 23:40:50 