To exit a room, you must open eight doors, that are initially closed. There are nine orbs that act on the doors, as follows:
Orb 1: Toggle door 1 (that is, close it if open, or open it if closed), open door 3 (if already open, leave it that way), and close door 5 (if already closed, leave it that way)
Orb 2: Open 3, close 4, open 7
Orb 3: Toggle 3, close 7, open 8
Orb 4: Open 1, open 3, toggle 5
Orb 5: Close 1, open 4
Orb 6: Toggle 2, open 3, close 5, open 6
Orb 7: Toggle 4 and 5
Orb 8: Open 3, close 7
Orb 9: Close 8
What is the shortest sequence of orbs you must touch in order to get all doors open?
This puzzle appears on level 3 of the "Deadly Rooms of Death (Architect's Edition)" game, also known as "DROD - King Dugan's Dungeon".
There are 23 sequences of 5 orbs that will open all the doors:
0 here represents closed; 1 represents open.
seq after 1st after 2nd after 3rd after 4th after 5th
13267 10100000 10000001 10100011 11100111 11111111
13627 10100000 10000001 11100101 11100111 11111111
16327 10100000 11100100 11000101 11100111 11111111
31267 00100001 10100001 10100011 11100111 11111111
31627 00100001 10100001 11100101 11100111 11111111
32167 00100001 00100011 10100011 11100111 11111111
32467 00100001 00100011 10101011 11100111 11111111
32564 00100001 00100011 00110011 01110111 11111111
32617 00100001 00100011 01100111 11100111 11111111
32654 00100001 00100011 01100111 01110111 11111111
32764 00100001 00100011 00111011 01110111 11111111
34267 00100001 10101001 10101011 11100111 11111111
34627 00100001 10101001 11100101 11100111 11111111
36127 00100001 01100101 11100101 11100111 11111111
36217 00100001 01100101 01100111 11100111 11111111
36254 00100001 01100101 01100111 01110111 11111111
43267 10101000 10001001 10101011 11100111 11111111
43627 10101000 10001001 11100101 11100111 11111111
46327 10101000 11100100 11000101 11100111 11111111
61327 01100100 11100100 11000101 11100111 11111111
63127 01100100 01000101 11100101 11100111 11111111
63217 01100100 01000101 01100111 11100111 11111111
63254 01100100 01000101 01100111 01110111 11111111
DECLARE SUB permute (a$)
CLS
seq$ = "123456789"
v(8) = 1
FOR i = 7 TO 1 STEP -1
v(i) = v(i + 1) * 2
NEXT
sh$ = seq$
DO
door = 0
FOR i = 1 TO 5
SELECT CASE MID$(seq$, i, 1)
CASE "1"
door = ((door XOR v(1)) OR v(3)) AND (255 - v(5))
CASE "2"
door = (door OR (v(3) + v(7))) AND (255 - v(4))
CASE "3"
door = (door OR v(8)) AND (255 - v(7)) XOR v(3)
CASE "4"
door = (door OR v(1) OR v(3)) XOR v(5)
CASE "5"
door = (door OR v(4)) AND (255 - v(1))
CASE "6"
door = (door OR v(6) OR v(3) XOR v(2)) AND (255 - v(5))
CASE "7"
door = door XOR v(4) XOR v(5)
CASE "8"
door = (door OR v(3)) AND (255 - v(7))
CASE "9"
door = door AND (255 - v(8))
END SELECT
h(i) = door
IF door = 255 THEN
s$ = LEFT$(seq$, i)
IF s$ <> prev$ THEN
PRINT s$; " ";
FOR j = 1 TO i
s = h(j)
b$ = ""
FOR dp = 1 TO 8
b$ = LTRIM$(STR$(s MOD 2)) + b$
s = s \ 2
NEXT
PRINT b$; " ";
NEXT
PRINT
prev$ = s$
END IF
END IF
NEXT
permute seq$
LOOP UNTIL seq$ = sh$
The permute subroutine is found elsewhere on the site.
|
Posted by Charlie
on 2006-09-29 15:39:01 |