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

Home > General
Mensa Maze (Posted on 2009-10-07) Difficulty: 3 of 5
You can navigate the grid below from the top-left yellow circle to the bottom-right yellow square by making only orthogonal (not diagonal) moves, going from one position to the next only if the shape and/or the color of the shape in the entered cell is the same as that of the cell you are leaving.

  • What path has the minimum number of moves without going through the same cell twice?
  • What path has the maximum number of moves without going through the same cell twice?

  Submitted by Charlie    
Rating: 3.0000 (3 votes)
Solution: (Hide)
Specifying successive positions by two digits: rc, where r is the row number and c is the column number, these are the valid paths (11 at the beginning and 66 at the end are assumed):

12 13 14 24 23 33 32 42 41 51 52 62 63 53 54 44 34 35 25 26 36 46 56 55 65
12 13 14 24 23 33 32 42 41 51 52 62 63 53 54 44 34 35 45 55 65
12 13 23 33 32 42 41 51 52 62 63 53 54 44 34 35 25 26 36 46 56 55 65
12 13 23 33 32 42 41 51 52 62 63 53 54 44 34 35 45 55 65
21 31 32 42 41 51 52 62 63 53 54 44 34 35 25 26 36 46 56 55 65
21 31 32 42 41 51 52 62 63 53 54 44 34 35 45 55 65

There are 25 entries in the longest list, and then getting to 66 is one more, for 26 moves in the longest path.

There are 17 entries in the shortest list, and then getting to 66 is one more, for 18 moves in the shortest path.

Translated into terms of the moves (Up, Down, Left or Right) the paths are:

RRRDLDLDLDRDRURUURURDDDLDR
RRRDLDLDLDRDRURUURDDDR
RRDDLDLDRDRURUURURDDDLDR
RRDDLDLDRDRURUURDDDR
DDRDLDRDRURUURURDDDLDR
DDRDLDRDRURUURDDDR


DECLARE SUB goFrom (rf!, cf!)
CLEAR , , 25000

DIM SHARED gu$(6, 6), bd(6, 6), rowHist(36), colHist(36), moveNo

DATA yc,yt,ys,bs,bc,yt
DATA yc,bs,yt,bt,ys,bs
DATA bc,bs,bt,ys,yc,bt
DATA yt,bt,yc,bs,yt,bs
DATA ys,yc,bs,bt,yc,bc
DATA bt,ys,bs,yc,yt,ys

FOR r = 1 TO 6
 FOR c = 1 TO 6
  READ gu$(r, c)
 NEXT
NEXT


bd(1, 1) = 1
goFrom 1, 1

SUB goFrom (rf, cf)
 FOR dr = -1 TO 1
  FOR dc = -1 TO 1
    IF dr = 0 OR dc = 0 THEN
      IF dr <> dc THEN
        rt = rf + dr: ct = cf + dc
        IF rt > 0 AND rt < 7 AND ct > 0 AND ct < 7 THEN
         IF LEFT$(gu$(rt, ct), 1) = LEFT$(gu$(rf, cf), 1) 
    OR RIGHT$(gu$(rt, ct), 1) = RIGHT$(gu$(rf, cf), 1) THEN
          IF bd(rt, ct) = 0 THEN
            bd(rt, ct) = 1
              IF rt = 6 AND ct = 6 THEN
                FOR i = 1 TO moveNo
                  PRINT LTRIM$(STR$(rowHist(i))); 
    LTRIM$(STR$(colHist(i))); " ";
                NEXT i
                PRINT
              ELSE
                moveNo = moveNo + 1
                rowHist(moveNo) = rt
                colHist(moveNo) = ct

                goFrom rt, ct

                moveNo = moveNo - 1
              END IF
            bd(rt, ct) = 0
          END IF
         END IF
        END IF
      END IF
    END IF
  NEXT
 NEXT
END SUB

translation of the form of the answer by:

OPEN "mensmzan.txt" FOR INPUT AS #1
DO
 LINE INPUT #1, l$
 l$ = LTRIM$(RTRIM$(l$)) + " 66 "
 v$ = "1": h$ = "1"
 DO
   ix = INSTR(l$, " ")
   IF ix = 0 THEN EXIT DO
   newV$ = LEFT$(l$, 1): newH$ = MID$(l$, 2, 1)
   l$ = LTRIM$(MID$(l$, ix + 1))
   dv = VAL(newV$) - VAL(v$)
   dh = VAL(newH$) - VAL(h$)
   SELECT CASE dv
     CASE -1
      PRINT "U";
     CASE 1
      PRINT "D";
     CASE 0
      SELECT CASE dh
       CASE -1
        PRINT "L";
       CASE 1
        PRINT "R";
      END SELECT
   END SELECT
   v$ = newV$: h$ = newH$
 LOOP
 PRINT
LOOP UNTIL EOF(1)


From the Mensa puzzle calendar for 2009, by Dr. Abbie F. Salny, Mark Danna and Fraser Simpson, Workman Publishing, New York. Puzzle for September 24.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Useful PostJacob Steven2021-12-29 08:13:14
Essay writing course linksJacob Steven2021-12-29 08:09:04
re: education doraamma2021-04-11 16:18:58
No SubjectCasey Bullock2020-12-17 02:31:12
Getting ready to defend a thesis John Kavita2020-12-05 04:56:42
re: education Winston692020-09-19 05:02:45
re: education Winston692020-09-19 05:02:21
vapeRoss York2020-09-07 23:11:14
No SubjectRoss York2020-09-07 23:10:05
No SubjectRoss York2020-09-07 23:07:03
vapeColton Hendricks2020-08-15 05:39:22
education September Dillon2020-05-28 05:54:52
amendeded bottemiller2009-10-07 20:28:07
GraphTraversered bottemiller2009-10-07 19:56:48
re(2): Best Minimum?Charlie2009-10-07 16:22:08
re(2): Best Minimum?Jim Keneipp2009-10-07 16:18:28
re: Best Minimum?Daniel2009-10-07 15:43:13
re: Best Minimum?Daniel2009-10-07 14:28:35
Best Minimum?Jim Keneipp2009-10-07 12:56:10
a startDaniel2009-10-07 12:02:35
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 (6)
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