Brain-Teaser 180: [Crates of books]
From The Sunday Times, 20th September 1964 [link]
A publisher dispatches crates of mixed books to retailers — Adventure (high price), Biography (medium price), and Crime (low price). The crates each contain an equal number of books, but, conforming to local tastes, all have different proportions of the three books, and in fact, within the invoice price of £54 per crate it takes exactly every possible combination of the three to supply his customers.
On taking stock he finds that to each 2 of A, he has sold 3 each of B and C.
Weeks later, to the same customers, and under the same conditions, he despatches a similar consignment, except that on this occasion the three books have a wider price range. One of the crates, however, is mistakenly packed in proportion: A:B:C = 4:3:2, instead of A:B:C = 3:2:4.
What is the true total value of this consignment?
(All book prices are exact shillings).
This puzzle was originally published with no title.
[teaser180]
Jim Randell 11:07 am on 5 February 2023 Permalink |
When the solution was published it was noted: “Only 43 attempted this “fifth-form” Brain-teaser (180) and only 15 accurately solved it”.
However I did find it was necessary to add the following conditions to arrive at a unique solution:
The two consignments are to the same customers, so presumably consist of the same number of crates, the same number of books per crate, the same value per crate, and the same distribution of books per crate.
Each crate contains books to a value of £54. At 20 shillings per pound this is 1080 shillings. (All following values are given in shillings).
Each create contains the same number of books say n, and the incorrectly packed crate is meant to be packed with books in the ratio A:B:C = 3:2:4, so n must be a multiple of 9 (say 9k).
So, given a value for n, we can determine the how many of each book are meant to be in the incorrectly packed crate, and consider prices that give the crate a total value of 1080. Then using these prices we can determine how many different packings there are (assuming at least 1 book of each type per crate), which gives us the total number of crates in each consignment. (And at this point I also found it necessary to assume that there were at least 3 crates in a consignment). We can then determine the total number of books of each type in the entire consignment, and check that these are in the ratio A:B:C = 2:3:3.
From these potential prices and packings we can select two candidates, one with a narrower range of prices and one with a wider range of prices. And we can then calculate the actual value of the incorrectly packed crate in the consignment with the wider price range to give the required answer.
This Python program runs in 1.91s.
Run: [ @replit ]
from enigma import (irange, inf, div, express, rev, unpack, unzip, ratio, subsets, printf) # construct prices (pA, pB, pC), such that: pA > pB > pC, for # quantities of books (nA, nB, nC) with a total value of t def prices(nA, nB, nC, t): # choose a price for the most expensive books for pA in irange(3, inf): r1 = t - pA * nA if r1 < 0: break # choose a price for the cheapest books for pC in irange(1, pA - 2): r2 = r1 - pC * nC if r2 < 0: break # calculate the price of the mid-prices books pB = div(r2, nB) if pB and pA > pB > pC: yield (pA, pB, pC) # construct numbers of books (nA, nB, nC) priced at (pA, pB, pC) # such that: nA + nB + nC = n, and the total value of the crate is t def crates(n, pA, pB, pC, t): for qs in express(t, [pC, pB, pA], min_q=1): if sum(qs) == n: yield rev(qs) # consider the number of books per crate (is a multiple of 9, say 9k) for k in irange(1, 63): # number of intended books in the incorrectly packed crate (nA, nB, nC) = (3 * k, 2 * k, 4 * k) n = nA + nB + nC # find possible prices, sorted by price range (narrow to wide) ps = list(prices(nA, nB, nC, 1080)) # we need at least 2 different prices if len(ps) < 2: continue # for each set of prices consider all possible crate packings # and record those that give total numbers of books in the consigment # in the ratio A:B:C = 2:3:3 rs = list() for (pA, pB, pC) in ps: # find all possible crate packings cs = list(crates(n, pA, pB, pC, 1080)) if len(cs) < 3: continue # require at least 3 different packings # sum the total numbers of books in the consignment (tA, tB, tC) = map(sum, unzip(cs)) if ratio(tA, tB, tC) == (2, 3, 3): rs.append((pA, pB, pC, cs)) if len(rs) < 2: continue # sort results by price range (narrow to wide) prange = unpack(lambda pA, pB, pC, cs: pA - pC) rs.sort(key=prange) # choose pairs with narrow and wide price ranges for (nr, wr) in subsets(rs, size=2): if not prange(nr) < prange(wr): continue # output solution printf("{n} books per crate") for (i, (pA, pB, pC, cs)) in enumerate((nr, wr), start=1): printf("[consignment {i}] prices (A, B, C) = ({pA}, {pB}, {pC})") tv = 0 for (nA, nB, nC) in cs: v = nA * pA + nB * pB + nC * pC printf("-> crate (A, B, C) = ({nA}, {nB}, {nC}); value = {v}") if i == 2 and ratio(nA, nB, nC) == (3, 2, 4): v = nC * pA + nA * pB + nB * pC printf("--> packed as (A, B, C) = ({nC}, {nA}, {nB}); value = {v}") tv += v printf("total value of consignment = {tv}") printf()Solution: The total value of the second consignment is 5672s (= £283 + 12s).
If the books are priced: A=21, B=16, C=10, then with 72 books per crate, we can make the following (A, B, C) crates contain books with a value of 1080s:
The total number of books of each type in the consignment is (90, 135, 135) which are in the ratio 2:3:3.
And the indicated crate [*] has books in the ratio 3:2:4.
The total value of the shipment is 5× 1080 = 5400.
If the prices of the books are subsequently changed to: A=27, B=17, C=5 (a wider price range), then the same set of crates can be made, and each crate still contains 72 books with a value of 1080.
But in the second consignment the 72 books in the starred crate [*] are incorrectly packed as (32, 24, 16).
Meaning there are 8 more copies of A, 8 more copies of B, and 16 fewer copies of C.
So the actual total value of the second shipment is: 8×27 + 8×17 − 16×5 = 272 more than before, i.e. 5400 + 272 = 5672.
Without the requirement that there are at least 3 crates in a shipment we can find additional solutions, such as:
Which may account for some of the incorrect entries received at the time.
LikeLike