# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1646: All lined up

From New Scientist #2812, 14th May 2011 [link]

In Joe’s brother’s orchard of 221 apple trees, the trees in the rows, and the rows of trees, are spaced 15 feet apart. One day, Joe was standing in line with the trees in one row on the edge of the orchard just 80 feet from the corner tree. Looking along the row he could see a line of seven trees and, when he had turned right round, a line of six trees. As he turned round slowly, he noticed that in many other directions two or more trees appeared in line. He counted the number of times this was so.

What was Joe’s total?

[enigma1646]

### One response to “Enigma 1646: All lined up”

1. jimrandell 7 December 2011 at 10:04 am

Using a couple of the Python standard classes makes this a very short program (and if you want to go further you can cram it all onto one line). Runtime: 58ms.

```from fractions import Fraction
from collections import Counter

ms = Counter()
for x in range(15, 255, 15):
for y in range(0, 195, 15):
ms[Fraction(y - 80, x)] += 1

print(len([m for m in ms.values() if m > 1]))
```

Solution: Joe’s total was 19.