## Teaser 2905: Trackword

**From The Sunday Times, 27th May 2018** [link]

George and Martha are tackling a Trackword problem which appears in magazines. Nine letters are placed in a 3×3 grid and you have to work from one square to a neighbour, proceeding up, down, left, right or diagonally until all nine squares have been visited to form a nine-letter word. You must start in the top-left corner. As an example, you can get the word

EIGHTFOLDfrom the following grid:George and Martha thought that would be interesting to work out how many possible routes there are which start in the top-left corner.

How many routes are there?

[teaser2905]

## Jim Randell 7:05 am

on27 March 2019 Permalink |(See also:

Grid Puzzle)There’s a handy [[

`grid_adjacency()`

]] function in theenigma.pylibrary to compute the adjacency matrix on a square grid.This Python program can be used to calculate the number of paths on an

m×ngrid. For the 3×3 grid it runs in 81ms.Run:[ @repl.it ]Solution:There are 138 different possible routes.From square 0 we can go to to the central square (4) or to an edge square (1 or 3), so we can just count the paths with prefix [0, 4] and [0, 1]. There will be the same number of paths with prefix [0, 3] as there are with prefix [0, 1].

LikeLike