The two mirror-image ways are:
98
52 46
32 20 26
21 11 9 17
14 7 4 5 12
8 6 1 3 2 10
98
46 52
26 20 32
17 9 11 21
12 5 4 7 14
10 2 3 1 6 8
Only in the second one is C > B.
DECLARE SUB fillLevel (lvl!, offset!)
DECLARE SUB addon (lvl!)
DIM SHARED pyra(6, 6)
DIM SHARED used(99)
DIM SHARED origLvl
CLS
addon 1
SUB addon (lvl)
IF lvl = 1 THEN strt = 1: ELSE strt = pyra(lvl - 1, 1) + 1
FOR new1 = strt TO 99
IF used(new1) = 0 THEN
used(new1) = 1
pyra(lvl, 1) = new1
origLvl = lvl
IF lvl > 1 THEN
fillLevel lvl - 1, 2
ELSE
addon lvl + 1
END IF
used(new1) = 0
pyra(lvl, 1) = 0
END IF
NEXT
END SUB
SUB fillLevel (lvl, offset)
trial = pyra(lvl + 1, offset - 1) - pyra(lvl, offset - 1)
IF trial < 1 THEN EXIT SUB
IF used(trial) THEN EXIT SUB
used(trial) = 1
pyra(lvl, offset) = trial
IF lvl = 1 THEN
IF origLvl = 6 THEN
FOR row = 6 TO 1 STEP -1
FOR col = 1 TO 7 - row
PRINT pyra(row, col);
NEXT
PRINT
NEXT
PRINT
ELSE
addon origLvl + 1
END IF
ELSE
fillLevel lvl - 1, offset + 1
END IF
used(trial) = 0
END SUB
98
52 46
32 20 26
21 11 9 17
14 7 4 5 12
8 6 1 3 2 10
98
46 52
26 20 32
17 9 11 21
12 5 4 7 14
10 2 3 1 6 8
Based on Enigma No. 1631,"Joe's Pyramid", by Bob Walker, New Scientist, 29 January 2011, page 24. |