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

Home > Logic
Colourful Knight's Tour (Posted on 2008-01-24) Difficulty: 3 of 5
A knight enters the grid at number 1 and then moves, as if he were on a chessboard, to number 2. He visits every square in numerical order, before exiting at number 64.

KEY:
Blue = cube numbers (1, 8, 27 and 64)
Green = squares which are not cubes (4, 9, 16, 25, 36 and 49)
Red = prime numbers (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59 and 61)
Yellow = multiples of ten (10, 20, 30, 40, 50 and 60)
Purple = multiples of 11 which are not prime (22, 33, 44 and 55)

One number has been added to get you started.

35

No Solution Yet Submitted by Josie Faulkner    
Rating: 4.9091 (11 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 3 of 20 |

The program did not require the 35 in that position, but there was still only one solution, so that was indeed just a hint:

DECLARE SUB place (row!, col!)
DATA bgryrwwb
DATA ywrrwwgr
DATA wwrwryrp
DATA wrwrwwwr
DATA pwrwrwry
DATA wgwwppwg
DATA rgwwrbrw
DATA ybwwwgyr

CLEAR , , 25000

DIM SHARED bd$(8, 8), b(8, 8), moveNo, solCt


FOR row = 1 TO 8
 READ r$
FOR col = 1 TO 8
 c$ = MID$(r$, col, 1)
 bd$(row, col) = c$
 SELECT CASE c$
  CASE "r": rCt = rCt + 1
  CASE "w": wCt = wCt + 1
  CASE "g": gCt = gCt + 1
  CASE "b": bCt = bCt + 1
  CASE "y": yCt = yCt + 1
  CASE "p": pCt = pCt + 1
 END SELECT
NEXT
NEXT
PRINT bCt; gCt; rCt; yCt; pCt; wCt, bCt + gCt + rCt + yCt + pCt + wCt

CLS
moveNo = 1
place 1, 1
place 1, 8

PRINT solCt


END

SUB place (row, col)
 b(row, col) = moveNo
 moveNo = moveNo + 1
 FOR dRow = -2 TO 2
  IF dRow <> 0 THEN
    dCol0 = 3 - ABS(dRow)
    FOR dCol = -dCol0 TO dCol0 STEP 2 * dCol0
      r = row + dRow: c = col + dCol
      good = 1
      IF r > 0 AND r < 9 AND c > 0 AND c < 9 THEN
        IF b(r, c) = 0 OR b(r, c) > moveNo THEN
          SELECT CASE moveNo
           CASE 1, 8, 27, 64
            IF bd$(r, c) <> "b" THEN good = 0
           CASE 4, 9, 16, 25, 36, 49
            IF bd$(r, c) <> "g" THEN good = 0
           CASE 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61
            IF bd$(r, c) <> "r" THEN good = 0
           CASE 10, 20, 30, 40, 50, 60
            IF bd$(r, c) <> "y" THEN good = 0
           CASE 22, 33, 44, 55
            IF bd$(r, c) <> "p" THEN good = 0
           CASE ELSE
            IF bd$(r, c) <> "w" THEN good = 0
  '          IF moveNo = 35 AND (r <> 8 OR c <> 4) THEN good = 0
          END SELECT
          IF good THEN
             b(r, c) = moveNo
             IF moveNo = 64 THEN
               solCt = solCt + 1
               OPEN "colrnite.txt" FOR APPEND AS #2
               FOR pRow = 1 TO 8
                FOR pCol = 1 TO 8
                 PRINT #2, "<font color="; CHR$(34); "#";
                 SELECT CASE bd$(pRow, pCol)
                  CASE "r": COLOR 12: PRINT #2, "ff0000";
                  CASE "g": COLOR 10: PRINT #2, "00dd00";
                  CASE "b": COLOR 9: PRINT #2, "0000ff";
                  CASE "y": COLOR 14: PRINT #2, "ffffa0";
                  CASE "p": COLOR 13: PRINT #2, "ff20c0";
                  CASE "w": COLOR 15: PRINT #2, "ffffff";
                 END SELECT
                 PRINT #2, CHR$(34); ">";
                 PRINT USING "###"; b(pRow, pCol);
                 PRINT #2, USING "###"; b(pRow, pCol);
                 PRINT #2, "</font>";
                 COLOR 7
                NEXT
                PRINT
                PRINT #2, "<br>"
               NEXT
               CLOSE 2
               DO: LOOP UNTIL INKEY$ > ""
             ELSE
               place r, c
             END IF
          END IF
        END IF
      END IF
    NEXT
  END IF
 NEXT
 moveNo = moveNo - 1
 b(row, col) = 0
END SUB

 

 
1 16 31 40 3 18 21 64
30 39 2 17 42 63 4 19
15 32 41 46 53 20 61 22
38 29 48 43 62 45 54 5
33 14 37 52 47 58 23 60
28 49 34 57 44 55 6 9
13 36 51 26 11 8 59 24
50 27 12 35 56 25 10 7

The white is hard to read on the light gray background, so:

  1 16 31 40  3 18 21 64
 30 39  2 17 42 63  4 19
 15 32 41 46 53 20 61 22
 38 29 48 43 62 45 54  5
 33 14 37 52 47 58 23 60
 28 49 34 57 44 55  6  9
 13 36 51 26 11  8 59 24
 50 27 12 35 56 25 10  7

Edited on January 24, 2008, 3:29 pm

Edited on January 24, 2008, 3:32 pm
  Posted by Charlie on 2008-01-24 15:28:28

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (17)
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