Alfonso has forgotten the password of his safe. However he remembers that:
- The number is a ten digit positive integer using each of the digits from 0 to 9 exactly once.
- The sum of the 2nd, 5th, 6th and 8th digits is a single digit number.
- The 4th digit is a perfect square.
- The 3rd digit is 1
- The sum of the 4th and 7th digits is a perfect square.
- The value of the 10th digit is twice that of the 2nd digit.
- The product of the 4th digit and the 6th digit is equal to that of the 2nd digit and the 10th digit.
- 5 is next to 6 but not 4.
From the above clues, can you help Alfonso to crack the password to open the safe?
DECLARE SUB permute (a$)
CLS
a0$ = "234567890": h$ = a0$
DO
a$ = LEFT$(a0$, 2) + "1" + MID$(a0$, 3)
d1 = VAL(MID$(a$, 1, 1))
d2 = VAL(MID$(a$, 2, 1))
d3 = VAL(MID$(a$, 3, 1))
d4 = VAL(MID$(a$, 4, 1))
d5 = VAL(MID$(a$, 5, 1))
d6 = VAL(MID$(a$, 6, 1))
d7 = VAL(MID$(a$, 7, 1))
d8 = VAL(MID$(a$, 8, 1))
d9 = VAL(MID$(a$, 9, 1))
d10 = VAL(MID$(a$, 10, 1))
IF d2 + d5 + d6 + d8 < 10 THEN
IF d4 = 0 OR d4 = 1 OR d4 = 4 OR d4 = 9 THEN
sq = d4 + d7
sr = INT(SQR(sq) + .5)
IF sr * sr = sq THEN
IF d10 = 2 * d2 THEN
IF d4 * d6 = d2 * d10 THEN
IF INSTR(a$, "56") > 0 OR INSTR(a$, "65") > 0 THEN
IF INSTR(a$, "54") = 0 AND INSTR(a$, "45") = 0 THEN
PRINT a$
END IF
END IF
END IF
END IF
END IF
END IF
END IF
permute a0$
LOOP UNTIL a0$ = h$
finds
8319427056
|
Posted by Charlie
on 2014-03-17 12:06:55 |