Sunday Times Teaser 3179 – Sums and Products
by Andrew Skidmore
Published Sunday August 27 2023 (link)
Mrs Green uses a dice game to improve the maths skills of her pupils. The children sit four to a table and each child throws five dice. Points are awarded according to the sum and product for each child; bonus points are awarded if the five scores contain three or more of the same number.
At Liam’s table all four children had the same sum but all achieved that sum in different ways. Surprisingly, all of the twenty dice scored more than one and no bonus points were awarded. The distribution of scores was: sixes…5; fives…4; fours…2; threes…4; twos…5. Liam had the highest product.
What, in ascending order, were Liam’s five scores?
5 Comments
Leave one →
No recursion this time.
Hi Frits,
It is quite fast but a lot faster in relative terms with combinations_with_replacement() in place of product().
Brian
You are right. As I got a time under 10ms I didn’t really bother about this.
Following is a small benchmark.
combinations_with_replacement() has probably been written in C.
My impression in looking at a lot of code is that “combinations with
replacement” is under appreciated!