# Programming the chess board in Logo

Two approaches to the same problem of making a chess board pattern in Logo. Breaking down a problem into smaller, easier-to-solve problems is a key skill of the computer programmer. When presented with the chess board task, a programmer wouldn’t think about how to solve the whole problem but she would immediately identify small parts of the solution that would be useful to have solved first. For instance, it would be useful to have a procedure that makes a square so she would code that first. Once this procedure is written, it’s easy to create a procedure that makes a whole row of squares. And once the row procedure is created, making a whole chess board is really quite trivial.

Here is an elegant solution:

```to board :size
repeat 8 [row :size fd :size]
end```
```to row :size
repeat 8 [square :size rt 90 fd :size lt 90]
lt 90 fd 8*:size rt 90
end```
```to square :size
repeat 4 [fd :size rt 90]
end```

Conversely, it is possible to see the task of making the chess board as a linear sequence of loads and loads of instruction. That approach results in disgusting code like this:

```to disaster
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20

rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
fd 20
rt 90
rt 90
fd 20
lt 90
lt 90
fd 160
rt 90
fd 20
end```