All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Rolling Die (Posted on 2009-11-19) Difficulty: 2 of 5
On the board below, someone has placed a die the same size as one square on the upper-left corner, with an X on its only marked face, on the top.

You proceed to roll the die, rotating it 90° about an edge that's on the board so as to get to the next square, with a new face of the cube now exposed. Continue doing this until the die is on the square marked 1, but with the X again on the top. What's the shortest way of doing this?

What's the shortest way if the goal is to get to the square marked 2, also with the X on top again? Likewise for the goals marked 3, 4, 5 and 6.

bonus:

What if, instead of an X, a Y was on the top face, in the correct orientation, and the goal was to get to the same numbered squares, in the correct orientation again? Is it possible? How?

X

 

 

 

 

1

 

 

 

 

 

2

 

 

 

 

 

3

 

 

 

 

 

4

 

 

 

 

 

5

 

 

 

 

 

6

  Submitted by Charlie    
Rating: 5.0000 (1 votes)
Solution: (Hide)
The shortest length paths for goals 1 through 6 have the lengths 7, 8, 7, 8, 9 and 10 respectively.

The following paths show how it can be done for the indicated goal squares:

RRRRDRU        1
RRDRURR        1
DRURRRR        1
DRRRRRU        1

RRRDRURD       2
RRRDRDRU       2
RRDRURDR       2
RDRURDRR       2
RDRRRURD       2
RDRRRDRU       2
RDRDRURR       2
DRURRRDR       2
DRURDRRR       2
DRRRDRUR       2

RRDRRRD        3
DRRRDRR        3

RDRDRRRD       4
DRRRDRDR       4

RRRRDRDDD      5
RRRRDDDRD      5
RRDRDRRDD      5
RRDRDDDRR      5
RRDDRRDRD      5
RRDDDRDRR      5
RDDRDRRRD      5
DRRRRRDDD      5
DRRRRDDRD      5
DRRRDRDDR      5
DRRRDDRRD      5
DRRDDRRRD      5
DRDRRRRDD      5
DRDRRDDRR      5
DRDDRRRRD      5
DRDDDRRRR      5
DDRRRRDRD      5
DDRRDRDRR      5
DDDRRRRRD      5
DDDRDRRRR      5

RRRDRDRDDD     6
RRRDRDDDRD     6
RRDRDRDRDD     6
RRDRDDDRDR     6
RRDDRDRDRD     6
RRDDDRDRDR     6
RDRRRDRDDD     6
RDRRRDDDRD     6
RDRDRDRRDD     6
RDRDRDDDRR     6
RDRDDRRDRD     6
RDRDDDRDRR     6
RDDDRDRRRD     6
DRRRDRDDDR     6
DRDRRRDRDD     6
DRDRRDDRDR     6
DRDRDRRRDD     6
DRDRDRDDRR     6
DRDDDRRRDR     6
DRDDDRDRRR     6
DDRRRDRDRD     6
DDRRDRDRDR     6
DDRDRRRDRD     6
DDRDRDRDRR     6
DDDRDRRRDR     6
DDDRDRDRRR     6

for the bonus:

RRRDRURD       2
RRDRURDR       2
RDRURDRR       2
RDRRRDRU       2
DRURDRRR       2
DRRRDRUR       2

RRRDLDRRRD     4
RRRDDDRDRU     4
RRDLDRRRDR     4
RRDRRRDLDR     4
RRDRDRURDD     4
RRDDRURDRD     4
RRDDDRDRUR     4
RDLDRRRDRR     4
RDRURRRDDD     4
RDRURDDRRD     4
RDRRRDLDRR     4
RDRRDDRURD     4
RDRDRURDDR     4
RDRDRRDDRU     4
RDRDDDRRRU     4
RDDRURDRDR     4
RDDRRDRDRU     4
RDDDRRRURD     4
RDDDRDRURR     4
DRURRRDDDR     4
DRURDRDRRD     4
DRURDDRRDR     4
DRRRURDRDD     4
DRRRDLDRRR     4
DRRDRDRURD     4
DRRDDRURDR     4
DRDRURRRDD     4
DRDRURDDRR     4
DRDRRDDRUR     4
DRDDDRRRUR     4
DDRURDRDRR     4
DDRRRURDRD     4
DDRRDRDRUR     4
DDRDRURRRD     4
DDDRRRURDR     4
DDDRDRURRR     4

RRRDRDDDRD     6
RRDRDDDRDR     6
RDRRRDRDDD     6
RDRDDDRDRR     6
RDDDRDRRRD     6
DRRRDRDDDR     6
DRDRRRDRDD     6
DRDDDRDRRR     6
DDRDRRRDRD     6
DDDRDRRRDR     6

For goals 2 and 6, these are a subset of the respective solutions to the main question.
For goal 4, the bonus requires more steps (10) than for the main question (8).

The bonus seems impossible for odd numbered goals.

DECLARE SUB moveIt ()
DECLARE FUNCTION pathPiece$ (o$, r!, c!)
CLEAR , , 25000

DIM SHARED orient$, row, col, goalRow, mvHist$, minMoves, path$
DIM SHARED minM$(6)
CLS

FOR goalRow = 1 TO 6
  orient$ = "t": row = 1: col = 1
  path$ = pathPiece$(orient$, row, col)
  minMoves = 30
  moveIt
  DO: LOOP UNTIL INKEY$ > ""
NEXT

FOR i = 1 TO 6
   PRINT minM$(i)
NEXT

SUB moveIt
 FOR dr = -1 TO 1
 FOR dc = -1 TO 1
   saveOrient$ = orient$
   saveRow = row: saveCol = col
   IF (dr = 0 OR dc = 0) AND (ABS(dr) = 1 OR ABS(dc) = 1) THEN
     newRow = row + dr: newCol = col + dc
     IF newRow > 0 AND newRow <= 6 THEN
     IF newCol > 0 AND newCol <= 6 THEN
      ho = INSTR("wteb", orient$)
      IF ho > 0 AND ABS(dc) = 1 THEN
        ho = ho - dc: IF ho < 1 THEN ho = ho + 4:  ELSE IF ho > 4 THEN ho = ho - 4
        orient$ = MID$("wteb", ho, 1)
      END IF
      vo = INSTR("ntsb", orient$)
      IF vo > 0 AND ABS(dr) = 1 THEN
        vo = vo - dr: IF vo < 1 THEN vo = vo + 4:  ELSE IF vo > 4 THEN vo = vo - 4
        orient$ = MID$("ntsb", vo, 1)
      END IF
      code$ = pathPiece$(orient$, newRow, newCol)
      IF INSTR(path$, code$) = 0 AND LEN(path$) <= minMoves THEN
        path$ = path$ + code$

        row = newRow: col = newCol
        drct = 2 * dr + dc + 3
        direct$ = MID$("UL RD", drct, 1)
        mvHist$ = mvHist$ + direct$
        IF col = 6 AND row = goalRow AND orient$ = "t" THEN
         minMoves = LEN(path$)
         minM$(goalRow) = mvHist$
         PRINT mvHist$, goalRow
        ELSE
         moveIt
        END IF
        mvHist$ = LEFT$(mvHist$, LEN(mvHist$) - 1)

        path$ = LEFT$(path$, LEN(path$) - 1)
      END IF
     END IF
     END IF
   END IF
   row = saveRow: col = saveCol
   orient$ = saveOrient$
 NEXT
 NEXT
END SUB

FUNCTION pathPiece$ (o$, r, c)
 n = ((r - 1) * 6 + c - 1) * 6 + INSTR("tbnsew", o$)
 pathPiece$ = CHR$(n)
END FUNCTION

for the bonus:

DECLARE FUNCTION pathPiece$ (o$, o2$, r!, c!)
DECLARE SUB moveIt ()
CLEAR , , 25000

DIM SHARED orient$, orient2$, row, col, goalRow, mvHist$, minMoves, path$
DIM SHARED minM$(6)
CLS

FOR goalRow = 1 TO 6
  orient$ = "t": orient2$ = "n": row = 1: col = 1
  path$ = pathPiece$(orient$, orient2$, row, col)
  minMoves = 17
  moveIt
  PRINT goalRow; "end"
  DO: LOOP UNTIL INKEY$ > ""
NEXT

FOR i = 1 TO 6
   PRINT minM$(i)
NEXT

SUB moveIt
 FOR dr = -1 TO 1
 FOR dc = -1 TO 1
   saveOrient$ = orient$
   saveOrient2$ = orient2$
   saveRow = row: saveCol = col
   IF (dr = 0 OR dc = 0) AND (ABS(dr) = 1 OR ABS(dc) = 1) THEN
     newRow = row + dr: newCol = col + dc
     IF newRow > 0 AND newRow <= 6 THEN
     IF newCol > 0 AND newCol <= 6 THEN
      ho = INSTR("betw", orient$)
      IF ho > 0 AND ABS(dc) = 1 THEN
        ho = ho - dc: IF ho < 1 THEN ho = ho + 4:  ELSE IF ho > 4 THEN ho = ho - 4
        orient$ = MID$("betw", ho, 1)
      END IF
      ho = INSTR("betw", orient2$)
      IF ho > 0 AND ABS(dc) = 1 THEN
        ho = ho - dc: IF ho < 1 THEN ho = ho + 4:  ELSE IF ho > 4 THEN ho = ho - 4
        orient2$ = MID$("betw", ho, 1)
      END IF
      vo = INSTR("bstn", orient$)
      IF vo > 0 AND ABS(dr) = 1 THEN
        vo = vo - dr: IF vo < 1 THEN vo = vo + 4:  ELSE IF vo > 4 THEN vo = vo - 4
        orient$ = MID$("bstn", vo, 1)
      END IF
      vo = INSTR("bstn", orient2$)
      IF vo > 0 AND ABS(dr) = 1 THEN
        vo = vo - dr: IF vo < 1 THEN vo = vo + 4:  ELSE IF vo > 4 THEN vo = vo - 4
        orient2$ = MID$("bstn", vo, 1)
      END IF
      code$ = pathPiece$(orient$, orient2$, newRow, newCol)
      IF INSTR(path$, code$) = 0 AND LEN(path$) / 2 <= minMoves THEN
        path$ = path$ + code$

        row = newRow: col = newCol
        drct = 2 * dr + dc + 3
        direct$ = MID$("UL RD", drct, 1)
        mvHist$ = mvHist$ + direct$
        IF col = 6 AND row = goalRow AND orient$ = "t" AND orient2$ = "n" THEN
         minMoves = LEN(path$) / 2
         minM$(goalRow) = mvHist$
         PRINT mvHist$, goalRow
        ELSE
         moveIt
        END IF
        mvHist$ = LEFT$(mvHist$, LEN(mvHist$) - 1)

        path$ = LEFT$(path$, LEN(path$) - 2)
      END IF
     END IF
     END IF
   END IF
   row = saveRow: col = saveCol
   orient$ = saveOrient$
   orient2$ = saveOrient2$
 NEXT
 NEXT
END SUB

FUNCTION pathPiece$ (o$, o2$, r, c)
 n = ((r - 1) * 6 + c - 1) * 6 + INSTR("tbnsew", o$) + 5
 pathPiece$ = CHR$(n) + CHR$(INSTR("tbnsew", o2$) - 1)
END FUNCTION




Based on Enigma No. 1565, "It's a rollover", by Bob Walker, New Scientist, 3 October 2009, page 28.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Puzzle Thoughts K Sengupta2023-03-17 23:38:56
re(3): solutionbrianjn2009-11-20 22:17:18
re(2): solutionVishal Gupta2009-11-20 14:43:47
re: solutionbrianjn2009-11-19 19:49:05
Solutiona non-bonus solutionDej Mar2009-11-19 17:45:58
Hints/TipssolutionVishal Gupta2009-11-19 15:29:38
dru my solutionsJer2009-11-19 15:17:32
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (19)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information