### by Colin Vout

#### Published Sunday July 04 2021 (link)

Twelve men from our football squad had turned up for training, and I’d promised them a game of six-a-side at the end of the session; so while they were off on a gentle three-mile run I worked out what the two teams would be. They were wearing their squad numbers, which had one or two digits: 2, 3, 4, 5, 6, 7, 8, 9, 15, and three others. It appealed to me when I found that I could divide them into two teams of six, such that the sum of the reciprocals of the squad numbers in each team equalled one exactly.

What were the squad numbers in the team containing number 2?

From → Uncategorized

I am much more interested in code elegance rather than speed but this is quite fast and runs in 1 millisecond on my PC using CPython.

@Brian, why may “f” not be part of “given” (line 14)?

Because if I allow ‘f’ to be in ‘given’ I would need to adopt a more complex approach. I was aware of this issue but decided not to add the extra complexity since it turned out not to be needed.

EDIT: The added complexity doesn’t cost as much as I thought it might so I have changed it to avoid this issue.

My simplistic programme is supported by a couple of lines arithmetic..

Nice and short.

I think the logic to find five numbers should be done immediately when D is updated (and D reset afterwards).

Thanks; Frits.
.
What I regret the most, is the division in line 11. An extra line comparing the corresponding products, would have eliminated the use of float in the programme all together.