### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,270)
- misc (3)
- project euler (2)
- puzzle (67)
- site news (50)
- tantalizer (69)
- teaser (7)

### Site Stats

- 206,376 hits

Programming Enigma Puzzles

5 March 2018

Posted by on **From New Scientist #2228, 4th March 2000** [link]

Sunny Bay fisherfolk have a tradition that when they return home with a catch of fish they take all the catch and divide it into three piles. Over the years they have pondered the question: given a particular number of fish, how many different ways can they be divided up? For example, they could divide up 10 fish in 8 ways, namely, (1, 1, 8), (1, 2, 7), (1, 3, 6), (1, 4, 5), (2, 2, 6), (2, 3, 5), (2, 4, 4) and (3, 3, 4).

One day the fisherfolk netted four large sea shells. On one side of each was one of the letters A, B, C and D and each shell carried a different letter. Each shell also had on its reverse one of the numbers 0, 1, 2, 3, 4, 5, 6, … The fisherfolk found that if they caught N fish then the number of different ways of dividing them into three piles was:

[(A × N × N) + (B × N) + C] / D

rounded to the nearest whole number. (Whatever the number of fish, the calculation would never result in a whole number plus a half; so there was no ambiguity about which whole number was the nearest).

I recall that D was less than 21, that is, the number on the reverse of the shell with D on it was less than 21. Also A and C were different.

What were A, B, C and D?

[enigma1072]

%d bloggers like this:

This Python program eliminates possible candidate coefficient sets

(a, b, c, d)until there is only one remaining.It runs in 99ms.

Run:[ @repl.it ]Solution:A=1, B=0, C=0, D=12.That is, the number of partitions of

ninto three positive integers is the nearest integer ton² / 12.So we could write code to calculate the number of decompositions into 3 piles as:

The program starts with 292 candidate coefficient sets that give a result of 0 for

n = 0, 1, 2, and then considers increasing values ofndiscarding coefficient sets that don’t match the computed number of partitions. By the time it has reachedn = 9it has narrowed the set of possibilities down to a single value, giving the solution.The number of partitions appears in OEIS as sequence A069905 (which gives a link to a general proof of the formula [link]), although this is a subsidiary entry to A001399.

Incidentally, the constraint that A and C be different is required because

(n² + 1) / 12also works.