last this
week week
1 1 x
2 4
3 6
4 2
5 10
6 3
7 14
8 16
9 18
10 5
11 22
12 9
13 26
14 7
15 12
16 8
17 34
18 15
19 38
20 25
21 28
22 11
23 23 x
24 27
25 20
26 13
27 24
28 21
29 29 x
30 33
31 31 x
32 40
33 30
34 17
35 0
36 39
37 37 x
38 19
39 36
40 35
Non-movers marked with an x. Assumption here is that a lower number is higher on the chart.
DECLARE SUB place (p!)
CLEAR , , 25000
DIM SHARED used(40), h(40), downCt, upCt
used(1) = 1: h(1) = 1
used(23) = 1: h(23) = 23
used(29) = 1: h(29) = 29
used(31) = 1: h(31) = 31
used(32) = 1
used(37) = 1: h(37) = 37
place 2
SUB place (p)
FOR mov = 2 TO p
IF p MOD mov = 0 THEN
try = p - mov
IF try > 0 THEN
IF used(try) = 0 THEN
used(try) = 1
h(p) = try
upCt = upCt + 1
SELECT CASE p
CASE 22, 28, 30, 34, 36
place p + 2
CASE 40
IF downCt = 16 AND upCt = 18 THEN
FOR i = 1 TO 40
PRINT USING "## ## "; i; h(i);
IF i = h(i) THEN PRINT "x": ELSE PRINT
NEXT
PRINT downCt, upCt
END IF
CASE ELSE
place p + 1
END SELECT
upCt = upCt - 1
h(p) = 0
used(try) = 0
END IF
END IF
try = p + mov
IF try < 41 THEN
IF used(try) = 0 THEN
used(try) = 1
h(p) = try
downCt = downCt + 1
SELECT CASE p
CASE 22, 28, 30, 34, 36
place p + 2
CASE 40
IF downCt = 16 AND upCt = 18 THEN
FOR i = 1 TO 40
PRINT USING "## ## "; i; h(i);
IF i = h(i) THEN PRINT "x": ELSE PRINT
NEXT
PRINT downCt, upCt
END IF
CASE ELSE
place p + 1
END SELECT
downCt = downCt - 1
h(p) = 0
used(try) = 0
END IF
END IF
END IF
NEXT
END SUB
Adapted from Giant Book of Mensa Mind Challenges, edited by Todd Johnson,
"Nearly Impossible Brain Bafflers" chapter,
page 176: puzzle #26. |