Brain-Teaser 466: [Ferry fare]
From The Sunday Times, 3rd May 1970 [link]
The ferryman collected 5s. when he took six horses and two prams across the river, and 5s. 9d. when he brought six bicycles and three wheel-barrows back. He is at present collecting 4s. for two wheel-barrows, three prams and a horse.
His idiosyncratic tariff of charges is for vehicles and animals only, and not for people.
How much will he collect for his next cargo, which awaits him on the far bank and consists of one wheel-barrow, one horse, one bicycle and one pram?
This puzzle was originally published with no title.
[teaser466]
Jim Randell 7:32 am on 23 March 2019 Permalink |
We note that 1 shilling (s) = 12 pence (d).
So we have the following 3 equations (expression amounts in pence):
There are 3 equations in 4 variables, so we cannot work out the actual prices. But we don’t need to, we are looking for the price of a particular combination.
So, we can consider looking for multipliers t, u, v for the equations that give the required combination:
Then the amount to be collected (in pence) is then:
Equating the coefficients of w, h, b, p we get the following 4 equations:
which is 4 equations in 3 variables, so we try to solve them:
From [b]:
Then from [w]:
and from [h]:
And we can check [p] gives the right value (which it does).
So the equations are consistent, and the solution is:
Solution: He will collect 2s 7d.
Here’s a Python program that does the same thing using the Gaussian elimination solver for linear equations from the enigma.py library. (Originally written for Enigma 287).
It runs in 87ms.
from enigma import (Matrix, printf) # solve the equations (t, u, v) = Matrix.linear([[0, 3, 2], [6, 0, 1], [0, 6, 0], [2, 0, 3]], [1, 1, 1, 1]) # determine the answer in pence x = t * 60 + u * 69 + v * 48 # ... in shillings and pence (s, d) = divmod(x, 12) printf("fare = {s}s {d}d [t={t} u={u} v={v}]")LikeLike