Nine Dot

9 dots

The nine dots puzzle first appeared in a magazine in 1907. The dots were eggs, and the task was to connect the eggs in the smallest number of strokes. Today the puzzle is often presented as an exercise in “thinking outside of the box” where the solution lies. Can you connect the nine dots in four straight lines without lifting a pen?


Select the button below to open the Python program in a new window. Run the program and read the lines of code to see if you can understand how it works. It will be helpful to arrange your display so that you can have this browser window on one side of the screen and the code on the other.

Watch this video to learn about the new concepts shown in the program:

Knowledge Organiser

Command summary

The new commands used in this program and others that may be useful. Select them below to learn more:


Moves the turtle to coordinates 0, 0 known as the origin.

turtle.setposition(x, y)

Positions the turtle at coordinates x, y. Positive numbers will be to the right / above the origin. Negative numbers will be to the left / below the origin.


Puts the pen down. As the turtle moves it will draw a line between its old position and its new position.


Lifts the pen up. As the turtle moves it will not draw a line.

Draws a circle from the middle of the turtle with a radius x.


Questions to think about with this program to check your understanding:

Purpose question

Explain what the purpose of the numbers 0 and 2 are in line 32.


The numbers in line 32 are coordinates in the nine dot grid. The first number is the column and the second number is the row starting at zero.

(0,0) is the bottom left dot.

(2, 0) is the bottom right dot.

(1, 1) is the middle dot.

(0, 2) is the top left dot.

(2, 2) is the top right dot.

Reason question

Explain why a subprogram was used in line 23-24 for a single command and called in line 32 with move(0, 2) instead of writing:

turtle.setposition(0, 100)

  1. Using a subprogram for the conversion of coordinates into a position makes the code from line 32 easier to read.
  2. The calculation is only coded once instead of each time it is needed. This makes the program easier to debug, reducing the chance of calculation errors.
  3. When solving the puzzle you only need to think about the dot on the grid and not the position of the dot on the canvas.


Success Criteria

Change the program below so that it:

  1. Solves the nine dot puzzle in four lines of code. Lines 32, 34, 36 and 38. The turtle must start at the bottom left dot.

Typical inputs and outputs from the program would be:


Run your code to check that your program has met the success criteria and produces the required output.

Craig'n'Dave logo

Craig ‘n’ Dave

Bett Awards 2024 Finalist