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

 Travelling Knight (Posted on 2007-09-02)
Place the numbers 1 to 64 in the grid, so that each number is a knight's move away from its neighbour. The numbers 1 and 64 are also a knight's move away from each other. So, for example, the numbers 7 and 9 would each be a knight's move away from number 8.

The letters c and s to the right and below the grid indicate where the cubes and squares are situated.

C. Only one number in the twenties.
D. Nothing divisible by 21.
F. Only two numbers in the thirties. Total 210.
G. Three numbers in the thirties.

2. Nothing less than 20.
3. No number in the thirties.
4. Total 214.
6. Nothing divisible by 6 or 11. Only one number in the thirties.
7. Only one number divisible by 10.
8. Only one number divisible by 10.

 1 2 3 4 5 6 7 8 A 40 54 c s s B c C 6 s D E c s F 1 14 c s s G 37 59 s H 19 34 s s c s c c s s s s c s s

 See The Solution Submitted by Josie Faulkner Rating: 4.4000 (10 votes)

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

The following three knight's tours satisfy the diagram (including the square and cube counts), but only the last one also satisfies the clues:

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

A compiled VB 5.0 program took

4664.25 seconds = 1 h 17 m 44.25 s

to find the

3 solutions.

Run time would vary of course from computer to computer.

Only in the last solution does row F total 210.
Also, only in the last solution does column 4 total 214.

In VB 5.0:

Dim b(8, 8), moveNo, sCt, ways, cubeRow(8), sqRow(8), cubeCol(8), sqCol(8)

Private Sub Command1_Click()
b(1, 1) = 40
b(1, 3) = 54
b(3, 5) = 6
b(6, 3) = 1
b(6, 6) = 14
b(7, 2) = 37
b(7, 4) = 59
b(8, 1) = 19
b(8, 8) = 34

sqCol(2) = 1
sqCol(3) = 1 ' excludes 1
sqCol(4) = 2
sqCol(5) = 1
sqCol(8) = 2
sqRow(1) = 2
sqRow(3) = 1
sqRow(5) = 1
sqRow(6) = 1 ' excludes 1
sqRow(7) = 1
sqRow(8) = 1

cubeCol(3) = 0 ' excludes 1
cubeCol(5) = 1
cubeCol(6) = 2
cubeRow(1) = 1
cubeRow(2) = 1
cubeRow(5) = 1
cubeRow(6) = 0 ' excludes 1

moveNo = 1
tm = Timer

place 6, 3

Print sCt
Print Timer - tm
Print ways
End Sub

Sub place(frow, fcol)
DoEvents
For dr = -2 To 2 Step 4
For dc = -1 To 1 Step 2
GoSub tryMove
Next
Next
For dc = -2 To 2 Step 4
For dr = -1 To 1 Step 2
GoSub tryMove
Next
Next
Exit Sub

tryMove:
moveNo = moveNo + 1
trow = frow + dr
tcol = fcol + dc
If trow > 0 And trow <= 8 And tcol > 0 And tcol <= 8 Then
good = 1
If moveNo = 4 Or moveNo = 9 Or moveNo = 16 Or moveNo = 25 Or moveNo = 36 Or moveNo = 49 Or moveNo = 64 Then
If sqCol(tcol) < 1 Or sqRow(trow) < 1 Then
good = 0
End If
End If
If moveNo = 8 Or moveNo = 27 Or moveNo = 64 Then
If cubeCol(tcol) < 1 Or cubeRow(trow) < 1 Then
good = 0
End If
End If
If good Then
If b(trow, tcol) = moveNo Then save = 1 Else save = 0
If b(trow, tcol) = 0 Or save Then
b(trow, tcol) = moveNo
Select Case moveNo
Case 6, 14, 19, 34, 37, 40, 54, 59
good = save
End Select
If good Then
Select Case moveNo
Case 4, 9, 16, 25, 36, 49, 64
sqCol(tcol) = sqCol(tcol) - 1
sqRow(trow) = sqRow(trow) - 1
Case 8, 27, 64
cubeCol(tcol) = cubeCol(tcol) - 1
cubeRow(trow) = cubeRow(trow) - 1
End Select

If moveNo < 64 Then
place trow, tcol
Else
ways = ways + 1
Print "w "; ways
Open "traveling knight.txt" For Append As #2
For rp = 1 To 8
For cp = 1 To 8
f\$ = Right\$("   " + Format(b(rp, cp), "##"), 3)
Print f\$;
Print #2, f\$;
Next
Print
Print #2,
Next
Print
Print #2,
Close 2
End If

Select Case moveNo
Case 4, 9, 16, 25, 36, 49, 64
sqCol(tcol) = sqCol(tcol) + 1
sqRow(trow) = sqRow(trow) + 1
Case 8, 27, 64
cubeCol(tcol) = cubeCol(tcol) + 1
cubeRow(trow) = cubeRow(trow) + 1
End Select
End If

If save = 0 Then b(trow, tcol) = 0
End If
End If
End If
moveNo = moveNo - 1
Return

End Sub

Edited on September 3, 2007, 1:15 am
 Posted by Charlie on 2007-09-03 01:14:18

 Search: Search body:
Forums (0)