Tagged: by: P Woolfenden Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 7:30 am on 3 March 2020 Permalink | Reply
    Tags: by: P Woolfenden   

    Brain-Teaser 514: [Picnic buns] 

    From The Sunday Times, 18th April 1971 [link]

    On the occasion of the Early Risers Aquatic Club Easter Regatta, Mrs Perch packed a large picnic hamper, including nine dozen small buns, and dispatched her husband with seven of their children, all of different ages under 17, to enjoy the occasion.

    At lunch time the family party attacked the buns with gusto, but Mr Perch, having eaten more buns than any of the children, felt rather uncomfortable and managed to persuade Mr Fish, the President, to dispose of as many buns as he (Mr Perch) and his oldest child had eaten between them.

    Each of the children had eaten at least one bun, and there were sufficient left for each of the family party to eat another two at tea time and a further three on the journey home, which they dutifully did, returning home with an empty hamper.

    It happened that both after lunch and after tea, two of the children had each consumed three times as many buns and two of the children had consumed twice as many buns as one or other of the other children, and that by the time they arrived home each of the children had eaten exactly as many buns as he was years of age.

    How many buns were given to Mr Fish?

    This puzzle was originally published with no title.

    [teaser514]

     
    • Jim Randell's avatar

      Jim Randell 7:31 am on 3 March 2020 Permalink | Reply

      There are seven children of different ages, less than 17. Each child’s age is also the total number of buns eaten by that child during the day, so the minimum possible value is 6.

      This Python program considers possible ages, and checks that the numbers of buns consumed meet the required conditions. It runs in 70ms.

      from enigma import subsets, irange, div, icount_exactly as icount, printf
      
      # check numbers in the list s (each reduced by d) have exactly 2
      # matches that are 2x and 3x other numbers on the list
      def check(s, d):
        # calculate the required list
        s = list(x - d for x in s)
        # two must be 3x and two must be 2x other numbers on the list
        return all(icount(s, (lambda x: k * x in s), 2) for k in (2, 3))
      
      # consider possible ages for the children
      for s in subsets(irange(6, 16), size=7):
        # so the total number of buns eaten by the children is...
        t = sum(s)
        # the remaining buns are eaten by...
        # the father: x + 5
        # fish: (x + g - 5)
        # giving a total of: 2x + g
        g = s[-1]
        x = div(108 - t - g, 2)
        if x is None or not(x > g - 5): continue
      
        # the total number of buns eaten by the children after lunch and tea
        if not (check(s, 5) and check(s, 3)): continue
      
        # calculate the number of buns eaten by fish
        f = x + g - 5
        printf("fish = {f} [father = {x5}; ages = {s}]", x5=x + 5)
      

      Solution: Mr. Fish ate 21 of the buns.

      The children are aged: 6, 7, 8, 9, 12, 14, 15.

      And this is the total number of buns consumed by them at the end of the day. Accounting for 71 buns in total.

      They each ate 3 buns on the journey home, so after tea the bun tally was: 3, 4, 5, 6, 9, 11, 12.

      We see that two of the children have consumed 3× the number of buns as some other child: 9 (=3× 3), 12 (=3× 4).

      And also two of the children have consumed 2× the number of buns as some other child: 6 (=2× 3), 12 (=2× 6).

      And before that they each had 2 buns at tea time, so after lunch the bun tally was: 1, 2, 3, 4, 7, 9, 10.

      Again we have: 3 (=3× 1), 9 (=3× 3); and: 2 (=2× 1), 4 (=2× 2).

      So the children consumed 71 buns in all, leaving 37 to be accounted for.

      Of these Mr Fish ate 21, this being the same number that the father ate at lunch, plus the number the eldest child ate at lunch (= 10).

      So the father must have eaten 11 buns at lunch (which is more than the eldest child). With the 2 at tea, and 3 on the way home, this brings the fathers total to 16.

      So adding the total number of buns eaten by the children, the father and Mr. Fish we get: 71 + 16 + 21 = 108, exactly 9 dozen (= 9 × 12).

      Like

  • Unknown's avatar

    Jim Randell 9:00 am on 14 July 2019 Permalink | Reply
    Tags: by: P Woolfenden   

    Brain-Teaser 486: [Counting cards] 

    From The Sunday Times, 20th September 1970 [link]

    So as to encourage my four children to practise their arithmetic I have invented a game played with a standard pack of playing-cards. For scoring purposes an Ace counts as 1; Jack, Queen and King as 11, 12 and 13 respectively; and each other card by its numerical value.

    To make matters a little complicated, I decided that Hearts should count at face value, Clubs at double value, Diamonds at triple value, and Spades at quadruple value. Before each deal, one card is extract from the pack, and a Joker, valued at 50 points, is substituted.

    The cards are then dealt in the normal manner, and each child then counts up the points value of his or her hand. There is a small reward for the child who most rapidly correctly counts up his points, but the winner is the child with the highest total.

    At the conclusion of one such game, each of the totals was an exact multiple of 7, and the winner, Bert, had scored 42 more than Amy, who had beaten Don by 35. Poor Clara came last with 14 points fewer than Don.

    Which card had been replaced by the Joker?

    This puzzle was originally published with no title.

    [teaser486]

     
    • Jim Randell's avatar

      Jim Randell 9:01 am on 14 July 2019 Permalink | Reply

      The scores in order from lowest to highest are:

      C
      D = C + 14
      A = C + 49
      B = C + 91

      So the total number of points is:

      A + B + C + D = 4C + 154

      and C must be divisible by 7.

      This program creates a set of cards, and then looks at replacing one of the cards with a Joker (value 50), to find possible values for C (and hence A, B, D).

      It runs in 79ms.

      Run: [ @repl.it ]

      from enigma import irange, update, div, printf
      
      # multipliers
      mul = dict(H=1, C=2, D=3, S=4)
      
      # map each card to the corresponding score
      score = dict()
      for v in irange(1, 13):
        score.update(((v, k), m * v) for (k, m) in mul.items())
      
      # one card is replaced with a 50
      for k in score.keys():
        s = update(score, [(k, 50)])
        # total number of points
        t = sum(s.values())
      
        # score for C (= 7x)
        x = div(t - 154, 28)
        if x is None: continue
      
        # calculate the scores
        C = 7 * x
        (B, A, D) = (C + 91, C + 49, C + 14)
        printf("k={k} t={t}, A={A} B={B} C={C} D={D}")
      

      Solution: The card replaced by the Joker is the Jack of Clubs.

      This is the only card which gives a viable value for C.

      The scores are: B = 287; A = 245; D = 210; C = 196 (being 41×; 35×; 30×; 28× 7).

      We can get the program to additionally look for a way of dealing the cards that achieves the required scores. Fortunately there are many ways of dealing the cards. Here is one of them:

      A = 5♠ + 6♥ + 6♣ + 6♦ + 7♥ + 7♣ + 7♦ + 7♠ + 8♥ + 8♣ + 8♠ + X♦ + J♦
        = 20 +  6 + 12 + 18 +  7 + 14 + 21 + 28 +  8 + 16 + 32 + 30 + 33 = 245
      
      B = 8♦ + 9♥ + 9♣ + X♥ + X♣ + X♠ + J♥ + J♠ + Q♥ + Q♣ + Q♦ + K♥ + K♣
        = 24 +  9 + 18 + 10 + 20 + 40 + 11 + 44 + 12 + 24 + 36 + 13 + 26 = 287
      
      C = A♥ + A♣ + A♦ + A♠ + 2♥ + 2♣ + 2♦ + 2♠ + 3♥ + 6♠ + Q♠ + K♦ + K♠
        =  1 +  2 +  3 +  4 +  2 +  4 +  6 +  8 +  3 + 24 + 48 + 39 + 52 = 196
      
      D = 3♣ + 3♦ + 3♠ + 4♥ + 4♣ + 4♦ + 4♠ + 5♥ + 5♣ + 5♦ + 9♦ + 9♠ + JK
           6 +  9 + 12 +  4 +  8 + 12 + 16 +  5 + 10 + 15 + 27 + 36 + 50 = 210

      Like

  • Unknown's avatar

    Jim Randell 12:58 pm on 7 May 2019 Permalink | Reply
    Tags: by: P Woolfenden   

    Brain-Teaser 479: [Sixpences] 

    From The Sunday Times, 2nd August 1970 [link]

    My nephew Anselm collects good old-fashioned sixpences in a good old-fashioned piggy bank. These he recently extracted to audit and, while experimenting by putting them into two or more equal piles of two or more coins, found that there were exactly six different ways in which this could be done.

    From one of these combinations he returned one pile to the bank, and found that the balance could again be distributed into equal piles in exactly six different ways. On this second occasion he returned two equal piles from one of the combinations to the bank, and again found that the balance could be distributed into equal piles in six different ways only. He conducted this experiment a total of seven times, on the third occasion returning three piles, on the fourth four piles and so on, and after the seventh found that he had 24 sixpences remaining.

    On none of these occasions did he deposit as much as 25s. in the bank. His third deposit was twice as much as his sixth, and three times as much as his second. His fifth deposit was five times as large as his first.

    How many sixpences had he saved up?

    I have modified the wording slightly to clarify the puzzle.

    This puzzle was originally published with no title.

    [teaser479]

     
    • Jim Randell's avatar

      Jim Randell 12:59 pm on 7 May 2019 Permalink | Reply

      I assumed that making one pile with all the coins in does not count (as there are no solutions if it does count as one of the six configurations).

      1s = 12d, so at no point does Anselm deposit more than 52 coins. So he cannot start with more than (24 + 7×52 = 388) coins. This gives us a bounded solution space to search in, but it is more interesting to run the process backwards starting with the 24 final coins.

      This Python 3 program works backwards recursively to solve the problem. It runs in 79ms.

      from enigma import (divisors, div, printf)
      
      # possible pile sizes for n coins
      piles = lambda n: list(p for p in divisors(n) if 1 < p < n)
      
      # work backwards from <n> coins and <i> piles deposited to 1 pile deposited
      # i = number of piles deposited
      # n = number of coins
      # ps = possible pile sizes
      # return [(<n coins>, <n piles>), ...]
      def solve(n, i, ps, ss=[]):
        if i == 0:
          yield ss
        else:
          # consider the number of coins in each pile
          for k in ps:
            # i equally sized piles were deposited in the bank
            d = i * k
            # but not more than 52 coins
            if d > 52: break
            # the total number of coins before the deposit
            t = n + d
            # and t must have 6 possible piles numbers
            ds = piles(t)
            if not (len(ds) == 6): continue
            yield from solve(t, i - 1, ds, [(t, k)] + ss)
      
      # we end up with 24 coins
      N = 24
      for ss in solve(N, 7, piles(N) + [N]):
      
        # calculate the numbers of coins returned to the bank at each stage
        ds = list(i * k for (i, (_, k)) in enumerate(ss, start=1))
        # 3rd deposit was twice the 6th and 3 times the 2nd
        if not (ds[2] == 2 * ds[5] == 3 * ds[1]): continue
        # 5th deposit was 5 times the 1st
        if not (ds[4] == 5 * ds[0]): continue
      
        # output solution
        for (i, ((t, k), d)) in enumerate(zip(ss, ds), start=1):
          printf("{i}: {t} coins in {p} piles of {k}; deposit {i} piles = {d} coins", p=div(t, k))
        printf("started with {n} coins; finished with {N} coins", n=ss[0][0])
        printf()
      

      Solution: Anselm has 138 sixpences.

      Liked by 1 person

  • Unknown's avatar

    Jim Randell 11:46 am on 14 April 2019 Permalink | Reply
    Tags: by: P Woolfenden   

    Brain-Teaser 472: [Marital law] 

    From The Sunday Times, 14th June 1970 [link]

    The monogamous and aptly named state of Swindlonabad has a number of inflexible marital laws, these being that:

    (a) Each male citizen must marry on his 21st birthday.

    (b) Each married man must contribute on his wedding day and each subsequent birthday to an Inheritance Trust which must be maintained at exactly the number of shekels equal to the square of the number of years he has lived.

    (c) When an individual’s trust fund can be precisely divided among all his legitimate unmarried sons, each son receiving a number of shekels equal to the square of that son’s age, the father retires and he and his family are maintained by the state.

    Now Abdul the Prolific fathered a child during each year of his married life, and all of these children survived to attend his retirement revels. Although only two of his many children were girls, he complained bitterly that such a misfortune should overtake him twice in a decade. At the time of his retirement only one of his daughters was under the age of ten.

    How old were the two daughters at that time?

    This puzzle was originally published with no title.

    [teaser472]

     
    • Jim Randell's avatar

      Jim Randell 11:46 am on 14 April 2019 Permalink | Reply

      Let’s consider the situation where Abdul is married for 21 years or more (i.e. his age is at least 42).

      Children over 20 have no claim on the trust fund, so he will have children with ages, 0, 1, 2, 3, …, 20. But two of them are girls, one of which is under 10, and the other is up to 10 years older than that, and they will have no claim.

      This Python program runs in 80ms.

      Run: [ @repl.it ]

      from enigma import irange, is_square, printf
      
      # total amount for children from 0 to 20 if they each have a claim
      T = sum(i * i for i in irange(0, 20))
      
      # consider the age of one of the daughters (less than 10)
      for a in irange(0, 9):
        # and the age of the older dauger (10 or more, and within 10 years)
        for b in irange(10, a + 10):
          # does this give a viable amount in the fund?
          A = is_square(T - a * a - b * b)
          if A is None or A < 42: continue
          # output solution
          printf("a={a} b={b} A={A}")
      

      Solution: The daughters were 9 and 17.

      Abdul retired on his 50th birthday, so his trust fund was 2500 shekels.

      He also had 29 children, one born every year from his 21st year to his 49th year.

      So the children’s ages range from 0 to 28. The daughters are aged 9 and 17, and only those sons aged less than 21 have a claim on the fund.

      And we can verify that the total claim is the same as the amount in the trust fund:

      >>> sum(i * i for i in diff(irange(0, 20), [9, 17]))
      2500
      

      The following code shows the total amount in the trust fund, the ages of the claimants and the total claim on the fund on each of Abdul’s birthdays from 21 to 50:

      from itertools import count
      from enigma import printf
      
      # record the ages of the sons
      sons = []
      
      # consider Abdul's age
      for A in count(21):
        # the total amount in the fund
        fund = A * A
      
        # count the total claim on the fund
        claim = sum(x * x for x in sons)
      
        printf("A={A}: fund={fund}, sons={sons}, claim={claim}")
        if claim == fund: break
      
        # increase the ages of the sons
        sons = list(x + 1 for x in sons if x < 20)
      
        # and each year a child is born
        # but at age 32 and 40 these are daughters
        if A not in (32, 40): sons.insert(0, 0)
      

      Which gives the following output:

      A=21: fund=441, sons=[], claim=0
      A=22: fund=484, sons=[0], claim=0
      A=23: fund=529, sons=[0, 1], claim=1
      A=24: fund=576, sons=[0, 1, 2], claim=5
      A=25: fund=625, sons=[0, 1, 2, 3], claim=14
      A=26: fund=676, sons=[0, 1, 2, 3, 4], claim=30
      A=27: fund=729, sons=[0, 1, 2, 3, 4, 5], claim=55
      A=28: fund=784, sons=[0, 1, 2, 3, 4, 5, 6], claim=91
      A=29: fund=841, sons=[0, 1, 2, 3, 4, 5, 6, 7], claim=140
      A=30: fund=900, sons=[0, 1, 2, 3, 4, 5, 6, 7, 8], claim=204
      A=31: fund=961, sons=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], claim=285
      A=32: fund=1024, sons=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], claim=385
      A=33: fund=1089, sons=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], claim=506
      A=34: fund=1156, sons=[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], claim=649
      A=35: fund=1225, sons=[0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], claim=815
      A=36: fund=1296, sons=[0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], claim=1006
      A=37: fund=1369, sons=[0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], claim=1224
      A=38: fund=1444, sons=[0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], claim=1471
      A=39: fund=1521, sons=[0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], claim=1749
      A=40: fund=1600, sons=[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], claim=2060
      A=41: fund=1681, sons=[1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], claim=2406
      A=42: fund=1764, sons=[0, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], claim=2788
      A=43: fund=1849, sons=[0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], claim=2766
      A=44: fund=1936, sons=[0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20], claim=2740
      A=45: fund=2025, sons=[0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20], claim=2710
      A=46: fund=2116, sons=[0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20], claim=2676
      A=47: fund=2209, sons=[0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20], claim=2638
      A=48: fund=2304, sons=[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20], claim=2596
      A=49: fund=2401, sons=[0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20], claim=2550
      A=50: fund=2500, sons=[0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20], claim=2500
      

      and here it is as a graph:

      Like

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
Design a site like this with WordPress.com
Get started