Find a number
ABCDEFGHIJ such that
A is the count of how many 0's are in the number,
B is the number of 1's, and so on.
(Taken from http://einstein.et.tudelft.nl/~arlet/puzzles/logic.html)
It takes several runs of this program, manually halting it when a pattern emerges:
DIM ct(1, 9)
RANDOMIZE TIMER
FOR i = 0 TO 9
ct(0, i) = INT(RND(1) * 10)
NEXT
DO
FOR i = 0 TO 9
ct(1, i) = 0
NEXT
FOR i = 0 TO 9
ct(1, ct(0, i)) = ct(1, ct(0, i)) + 1
NEXT
FOR i = 0 TO 9
ct(0, i) = ct(1, i)
PRINT ct(0, i);
NEXT
PRINT
LOOP
Each successive line shows the count of the number of the given digit in the preceding line.
So when the following pattern is reached,
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
7 1 0 1 0 0 1 0 0 0
6 3 0 0 0 0 0 1 0 0
a solution hasn't been found, and it needs to try again. The RANDOMIZE TIMER causes a different seed to start. Eventually a run will produce the desired answer:
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
6 2 1 0 0 0 1 0 0 0
The above two seem to be the only two patterns achieved; I don't know if any other loop is possible.
|
Posted by Charlie
on 2009-03-30 11:23:32 |