Number the corners of a cube from 1 to 8, so that the sum of the four corners of every face is the same.
(In reply to
144 solutions to this problem by ritesh)
The following program verifies that there are 144 ways of assigning values 1  8 to positions A  H, that satisfy the conditions of the puzzle, but many such represent the same cube rotated into a new position. For any given cube, the 1, say, can be placed in any of the 8 positions; then any chosen vertex that's next to the 1 can be put in any one of three positions (D, B or E, if the 1 is at A) without changing the cube itself. So that's 8x3=24 ways of orienting the same cube, that show up as different assignments of 1  8 to A  H.
Also a reflection of the cube in a mirror is a trivial variation.
So 144/24 = 6 distinct cubes, which are really 2 trivial variations (reflections) of 3 distinct cubes, shown below:
1 8
4 5
7 2
6 3

1 8
4 5
6 3
7 2

1 8
6 3
4 5
7 2
For completeness consider also the mirror reflections of these cubes.
DECLARE SUB permute (a$)
CLS
s$ = "12345678": h$ = s$
DO
a = VAL(MID$(s$, 1, 1))
b = VAL(MID$(s$, 2, 1))
c = VAL(MID$(s$, 3, 1))
d = VAL(MID$(s$, 4, 1))
e = VAL(MID$(s$, 5, 1))
f = VAL(MID$(s$, 6, 1))
g = VAL(MID$(s$, 7, 1))
h = VAL(MID$(s$, 8, 1))
s1 = a + b + c + d
s2 = b + c + f + g
s3 = f + g + e + h
s4 = e + h + a + d
s5 = a + b + f + e
s6 = d + c + g + h
IF s1 = s2 AND s2 = s3 AND s3 = s4 AND s4 = s5 AND s5 = s6 THEN
x = d: y = b: z = e
IF x > y THEN SWAP x, y
IF y > z THEN SWAP y, z
IF x > y THEN SWAP x, y
ident$ = LTRIM$(STR$(x)) + LTRIM$(STR$(y)) + LTRIM$(STR$(z))
good = 1
FOR i = 1 TO ctU
IF ident$ = had$(i) THEN good = 0: EXIT FOR
NEXT
IF a = 1 AND good = 1 THEN
PRINT a; " "; d
PRINT " "; b; " "; c
PRINT " "; f; " "; g
PRINT e; " "; h
ctU = ctU + 1
PRINT
PRINT ""
PRINT
had$(ctU) = ident$
END IF
ct = ct + 1
END IF
permute s$
LOOP UNTIL s$ = h$
PRINT ct
Edited on November 29, 2007, 10:44 am

Posted by Charlie
on 20071129 10:32:39 