This is my representation of the
Minus Cube
Consider a 2 unit cube being composed of 8 unit cubes but with one removed.
The blue circles are the centres of where the unit cubes may be placed.
The unlabelled circle is the centre of the unoccupied space.
Any cube that is horizontally or vertically adjacent to the void (ie, connected by a straight line) may be moved into it (ignore gravity).
Your task is to report on three challenges:
1. The least number of moves to return the left graphic to that shown on the right, the "home" position.
After setting the
HOME position:
2. The least number of moves to create a reflection of the shown left cube, ie, exchange the
2 with the
4 and the
6 with the
void.
3. The least number of moves so that the sums of opposing vertices on the four major diagonals (
red) is
9; allow the blank to be
8.
Having played with the interactive, have you found another challenge we could share in Comments?
Note: Please exercise the utmost of care with the interactive as programming does not trap careless entries, so
on browser freeze you may need to wait about 30 secs for a pop-up dialog advice.
I chose the distant right plane as being the x-y plane (with 1, 3, 5 and empty in the initial left diagram), with z coming toward us and leftward.
currx, curry and currz refer to the current location of the blank, which is also represented by a zero in the array.
DECLARE SUB makeMove (mno!)
DECLARE FUNCTION checksol! (mno!)
CLEAR , , 25000
open "minus cube 1.txt" for output as #2
DIM SHARED cube(1, 1, 1), currx, curry, currz, hist(50), maxmove
maxmove = 15
cube(0, 0, 0) = 5 ' to be 6
cube(1, 0, 0) = 0 ' to be 7
cube(1, 1, 0) = 3 ' to be 3
cube(0, 1, 0) = 1 ' to be 2
cube(0, 0, 1) = 4 ' to be 5
cube(1, 0, 1) = 2 ' to be 0
cube(1, 1, 1) = 6 ' to be 4
cube(0, 1, 1) = 7 ' to be 1
currx = 1: curry = 0: currz = 0
makeMove 1
FUNCTION checksol (mno)
c = 0
IF currx = 1 AND curry = 0 AND currz = 1 THEN
IF cube(0, 0, 0) = 6 THEN
IF cube(1, 0, 0) = 7 THEN
IF cube(1, 1, 0) = 3 THEN
IF cube(0, 1, 0) = 2 THEN
IF cube(0, 0, 1) = 5 THEN
IF cube(1, 1, 1) = 4 THEN
IF cube(0, 1, 1) = 1 THEN
c = 1
FOR i = 1 TO mno
PRINT #2, hist(i);
NEXT
PRINT #2,
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
checksol = c
END FUNCTION
SUB makeMove (mno)
' x-axis
tox = 1 - currx
hist(mno) = cube(tox, curry, currz)
IF hist(mno) <> hist(mno - 1) THEN
SWAP cube(currx, curry, currz), cube(tox, curry, currz)
prex = currx
currx = tox
IF currx = 1 THEN ok = checksol(mno): ELSE ok = 0
IF ok = 0 AND mno < maxmove THEN
makeMove mno + 1
END IF
currx = prex
SWAP cube(currx, curry, currz), cube(tox, curry, currz)
END IF
' y-axis
toy = 1 - curry
hist(mno) = cube(currx, toy, currz)
IF hist(mno) <> hist(mno - 1) THEN
SWAP cube(currx, curry, currz), cube(currx, toy, currz)
prey = curry
curry = toy
IF curry = 0 THEN ok = checksol(mno): ELSE ok = 0
IF ok = 0 AND mno < maxmove THEN
makeMove mno + 1
END IF
curry = prey
SWAP cube(currx, curry, currz), cube(currx, toy, currz)
END IF
' z-axis
toz = 1 - currz
hist(mno) = cube(currx, curry, toz)
IF hist(mno) <> hist(mno - 1) THEN
SWAP cube(currx, curry, currz), cube(currx, curry, toz)
prez = currz
currz = toz
IF currz = 1 THEN ok = checksol(mno): ELSE ok = 0
IF ok = 0 AND mno < maxmove THEN
makeMove mno + 1
END IF
currz = prez
SWAP cube(currx, curry, currz), cube(currx, curry, toz)
END IF
END SUB
finds
3 6 2 4 7 1 6 2 4 7 5 6 2 3 7
2 4 7 6 4 7 5 2 7 5 6 1 2 6 5
2 4 7 1 3 6 4 7 5 2 6 3 2 6 7
2 6 7 4 5 2 6 7 4 1 2 6 7
2 6 3 2 6 4 7 1 2 3 4 7 5 6 7
(three ways in 15 moves and one way in 13 moves, making that the shortest:
2 6 7 4 5 2 6 7 4 1 2 6 7
)
|
Posted by Charlie
on 2013-04-18 16:39:44 |