Enigmatic Code

Programming Enigma Puzzles

Tantalizer 419: Wollycobblestones

From New Scientist #969, 2nd October 1975 [link]

There is a fascinating gallstone museum in the Yorkshire town of Wollycobble and folks come from miles around. But it costs a bit of brass to run and there has long been an admission charge. On the principle that the older you are the more interesting other folk’s insides become, the rate is traditionally 1p per year of age. Thus a 10 year old pays 10p, a chap aged 38 pays 38p and so on.

But prices have just had to go up. Yet tradition is sacred. So, craftily, the rate of 1p per year of age remains but now there are only 5p and 7p tickets. As a result the 10 year old still pays 10p (= 5p + 5p) and a 38 year old 38p (= 7p + 7p + 7p + 7p + 5p + 5p); but a 3 year old now pays 5p and an 18 year old 19p (= 7p + 7p + 5p).

The Bundle family makes an annual pilgrimage and, having this year 50 members of all different ages from 1 to 50, arrived expecting to pay £12.75.

At least how much extra did the wily curators extract from them by insisting on the new ticket system?


One response to “Tantalizer 419: Wollycobblestones

  1. Jim Randell 23 October 2019 at 10:38 am

    The [[ express() ]] function (as seen in Puzzle #10, Enigma 486) has been incorporated into the latest version of the enigma.py library.

    This gives a short Python program to solve the puzzle that runs in 95ms.

    Run: [ @repl.it ]

    from enigma import express, irange, cached, printf
    # ticket denominations
    ds = (5, 7)
    # charge is n if n can be expressed exactly
    # otherwise it is the same as the charge for n + 1
    charge = cached(lambda n: (n if any(express(n, ds)) else charge(n + 1)))
    # collect the total additional charge
    t = sum(charge(n) - n for n in irange(1, 50))
    # output solution
    printf("total additional charge = {t}p")

    Solution: The minimum extra charge is 19p.

    As 5 and 7 are co-prime there is a largest number that cannot be expressed with a combination of tickets. This number is: (5 × 7) – (5 + 7) = 23.

    The ages that are overcharged are:

    1 → 5p; +4p
    2 → 5p; +3p
    3 → 5p; +2p
    4 → 5p; +1p
    6 → 7p; +1p
    8 → 10p; +2p
    9 → 10p; +1p
    11 → 12p; +1p
    13 → 14p; +1p
    16 → 17p; +1p
    18 → 19p; +1p
    23 → 24p; +1p

    Giving a total extra charge of 19p.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: