Design a site like this with WordPress.com
Get started

Tagged: by: W. M. Greenway Toggle Comment Threads | Keyboard Shortcuts

  • Jim Randell 8:18 am on 9 October 2022 Permalink | Reply
    Tags: by: W. M. Greenway   

    Brain-Teaser 190: Towns and families 

    From The Sunday Times, 13th December 1964 [link]

    Cardiff and London share a line of latitude; Cardiff and Edinburgh share a line of longitude.

    The Archers, the Brewers, the Carters and the Drews are four married couples born and married in London, Cardiff, Edinburgh and Belfast. One of each sex was born in each city; one marriage took place in each city. No one was married in the city of his or her birth. Mrs Archer was the only woman married east of where she was born; Mr Archer was the only man married south of where he was born; Mr Brewer was the only man to marry a woman born north of him. Mr Carter and Mrs Drew were twins.

    Where were the Carters married?

    This puzzle was included in the book Sunday Times Brain Teasers (1974, edited by Ronald Postill).

    [teaser190]

     
    • Jim Randell 8:18 am on 9 October 2022 Permalink | Reply

      This Python program tries all possible arrangements.

      It runs in 55ms. (Internal runtime is 790µs).

      Run: [ @replit ]

      from enigma import (subsets, printf)
      
      # Belfast, Cardiff, Edinburgh, London
      cities = "BCEL"
      
      # assign North and East values (approximate latitude and longitude)
      N = dict(C=51.5, L=51.5, B=54.6, E=56.0)
      E = dict(B=-5.9, C=-3.2, E=-3.2, L=-0.1)
      
      # choose cities of birth for the men
      for (mA, mB, mC, mD) in subsets(cities, size=len, select="P"):
      
        # choose cities of birth for the women
        for (fA, fB, fC, fD) in subsets(cities, size=len, select="P"):
      
          # "Mr C and Mrs D were twins" (presumably born in the same place)
          if not (mC == fD): continue
      
          # "Mr B was the only man to marry a woman born N of him"
          if not (N[fB] > N[mB]): continue
          if any(N[f] > N[m] for (m, f) in zip((mA, mC, mD), (fA, fC, fD))): continue
      
          # choose cities for marriages
          for (wA, wB, wC, wD) in subsets(cities, size=len, select="P"):
            # no-one was married in the city of their birth
            if any(w == m or w == f for (m, f, w) in zip((mA, mB, mC, mD), (fA, fB, fC, fD), (wA, wB, wC, wD))): continue
      
            # "Mrs A is the only woman married east of her birth"
            if not (E[wA] > E[fA]): continue
            if any(E[w] > E[f] for (f, w) in zip((fB, fC, fD), (wB, wC, wD))): continue
      
            # "Mr A is the only man married south of his birth"
            if not (N[mA] > N[wA]): continue
            if any(N[m] > N[w] for (m, w) in zip((mB, mC, mD), (wB, wC, wD))): continue
      
            printf("          A B C D")
            printf("husband = {mA} {mB} {mC} {mD}")
            printf("wife    = {fA} {fB} {fC} {fD}")
            printf("wedding = {wA} {wB} {wC} {wD}")
            printf()
      

      Solution: The Carters were married in Belfast.

      The full solution is:

      Archer: husband = Edinburgh; wife = Belfast; married = London
      Brewer: husband = London; wife = Edinburgh; married = Cardiff
      Carter: husband = Cardiff; wife = London; married = Belfast
      Drew: husband = Belfast; wife = Cardiff; married = Edinburgh

      Like

  • Jim Randell 8:36 am on 2 October 2022 Permalink | Reply
    Tags: by: W. M. Greenway   

    Brain-Teaser 188: Family birthdays 

    From The Sunday Times, 29th November 1964 [link]

    I wrote to an American friend on the 3rd February 1964, and told him of the coincidence of our family birthdays. My wife and I, our three sons, and our four grandsons all have our birthdays on the same day of the week every year, though all our birthdays are different. When I wrote, I used the usual English form of the date — 3/2/64 — and I gave all our birthdays in that form also.

    My third son received a cable from my friend on his birthday in 1964, but later I was surprised to get a cable from him myself on my eldest son’s birthday. Next my eldest grandson received a cable on his right birthday, and I realised that we were all going to receive cables, but that my friend was, quite reasonably, reading the dates in the American form, i.e. he assumed that the letter had been sent on 2nd March 1964.

    However, I did not write to put him right, and my wife was the next person to get a cable; this was not on her birthday.

    What was the day and date of her birthday in 1964?

    This puzzle was included in the book Sunday Times Brain Teasers (1974, edited by Ronald Postill).

    [teaser188]

     
    • Jim Randell 8:37 am on 2 October 2022 Permalink | Reply

      The birthdays are on the same day of the week each year, so they cannot straddle 29th February.

      But in any case the letter was sent on 3/2, which was misinterpreted as 2nd March, so the birthdays must be after that date.

      This Python program runs in 57ms. (Internal run time is 434µs).

      Run: [ @replit ]

      from datetime import (date, timedelta)
      from enigma import (defaultdict, repeat, catch, subsets, printf)
      
      # reverse the day/month of a date
      rev = lambda d: catch(date, d.year, d.day, d.month)
      
      # is a date reversible?
      is_rev = lambda d: rev(d) == d
      
      # group days by day of the week
      g = defaultdict(list)
      # look for dates in 1964 that can be misinterpreted as US style dates
      inc = lambda x, i=timedelta(days=1): x + i
      for d in repeat(inc, date(1964, 1, 1)):
        if d.year > 1964: break
        # try US format
        d_ = rev(d)
        if not d_: continue
        # must be the same day of the week as the original date
        w = d.isoweekday()
        if d_.isoweekday() == w:
          g[w].append(d)
      
      # consider the day of the week
      for k in g.keys():
        # we need 9 dates the come after 2nd March
        for ds in subsets((d for d in g[k] if d > date(1964, 3, 2)), size=9):
          # the first birthday is the correct date (third son)
          if not is_rev(ds[0]): continue
          # the second birthday is not the correct date (eldest son, sent to setter)
          if is_rev(ds[1]): continue
          # the third birthday is the correct date (eldest grandson)
          if not is_rev(ds[2]): continue
          # the fourth birthday is not the correct date (sent to wife)
          if is_rev(ds[3]): continue
          # so the wife's birthday is ...
          d = rev(ds[3])
          # output solution
          printf("{d}", d=d.strftime("%A, %d %B %Y"))
      

      Solution: Her birthday is on: Saturday, 7th November 1964.

      There is only one set of dates that works:

      4/4 = 4th April, third son
      9/5 = 9th May, eldest son; misinterpreted as 5th September (the setter’s birthday)
      6/6 = 6th June, eldest grandson
      11/7 = 11th July; misinterpreted at 7th November (the setter’s wife’s birthday)
      8/8 = 8th August
      5/9 = 5th September, setter; misinterpreted at 9th May
      10/10 = 10th October
      7/11 = 7th November, setter’s wife; misinterpreted as 11th July
      12/12 = 12th December

      Like

  • Jim Randell 12:49 pm on 3 July 2022 Permalink | Reply
    Tags: by: W. M. Greenway   

    Brain-Teaser 120: Rugby results 

    From The Sunday Times, 14th July 1963 [link]

    At a certain stage in our all-against-all Rugby football competition the table of results read as follows. There had been no matches in which neither side had scored at all:

    What was the result of the match between A and B?

    Note: This problem was set when a try was worth 3 points, a penalty goal 3 points and a converted try 5 points. Match points are on the usual basis of 2 for a win and 1 for a draw.

    This puzzle was included in the book Sunday Times Brain Teasers (1974, edited by Ronald Postill).

    [teaser120]

     
    • Jim Randell 12:50 pm on 3 July 2022 Permalink | Reply

      There are certain scores which are not possible to make from combinations of 3 and 5 points.

      This Python program uses the [[ express() ]] function from the enigma.py library to determine what they are. We then use the [[ Football() ]] helper class to determine possible match outcomes and scorelines.

      It runs in 89ms.

      Run: [ @replit ]

      from enigma import (express, irange, peek, Football, digit_map, cache)
      
      # find scores that cannot be made from multiples of 3 and 5
      invalid = set(n for n in irange(0, 18) if not peek(express(n, [3, 5]), default=None))
      
      # scoring system (2 points for a win, 1 for a draw)
      football = Football(points=dict(w=2, d=1))
      
      # digits used in the table (10=A, 13=D, 15=F, 16=G, 18=I)
      d = digit_map(0, 18)
      
      # the table, goals for/against
      (table, gf, ga) = (dict(played="34432", points="55420"), "DGF53", "8AI88")
      
      # check for a valid score (and cache as we go along)
      @cache
      def valid(s):
        # unplayed?
        if s is None: return True
        # otherwise:
        # (0, 0) is not allowed
        if s == (0, 0): return False
        # reject invalid scores
        if invalid.intersection(s): return False
        # looks OK
        return True
      
      # find possible match outcomes
      for (ms, _) in football.substituted_table(table, d=d):
        # find possible scorelines
        for ss in football.substituted_table_goals(gf, ga, ms, d=d, valid=valid):
          # output solution
          football.output_matches(ms, ss, teams="ABCDE")
      

      Solution: The result of the A vs B match was a 5-3 win for A.

      The full results are:

      A vs B = 5-3
      A vs C = 5-5
      A vs D = 3-0
      A vs E = (unplayed)
      B vs C = 5-5
      B vs D = 5-0
      B vs E = 3-0
      C vs D = 0-5
      C vs E = 5-3
      D vs E = (unplayed)

      Like

  • Jim Randell 11:55 am on 26 June 2022 Permalink | Reply
    Tags: by: W. M. Greenway   

    Brain-Teaser 101: Midsummer birthday madness 

    From The Sunday Times, 3rd March 1963 [link]

    Midsummer Day, 1962 (June 24) was my youngest grandson John’s first birthday, and I was then able to claim that my nine grandchildren were aged 0, 1, 2, 3, 4, 5, 6, 7, and 8 years old (neglecting, of course, the odd days). They were all born in June, and if they are arranged in birthday order through the month the following facts are true:

    John is the middle grandchild;

    The sum of the dates of the last four is an exact multiple of the sum of the dates of the first four;

    The sum of the ages of the last four is two-thirds of the sum of the ages of the first four;

    The sum of the years of birth of the first three is equal to the sum of the years of birth of the last three;

    The intervals between birthdays are 0, 1, 2, 3, 4, 5, 6, and 7 days, but not in that order;

    Also:

    My eldest son’s two daughters are exactly two years apart;

    The twins were born four hours apart;

    Two children are as old as their dates of birth.

    What was the date of birth of the grandchild born in 1954?

    This puzzle was included in the book Sunday Times Brain  Teasers (1974, edited by Ronald Postill).

    There are now 700 Teaser puzzles available on the site!

    [teaser101]

     
    • Jim Randell 11:56 am on 26 June 2022 Permalink | Reply

      The ages are all different, so the twins must be born either side of midnight on the 24th, so John is one of the twins, and the other must have a birthday of the 25th. John is the youngest grandson, so his (younger) twin must be a girl.

      This Python program starts with the 24th in the middle of the order, and then chooses an ordering for the intervals to give the remaining dates. It then assigns the ages, and checks all the required conditions apply.

      It runs in 161ms.

      Run: [ @replit ]

      from enigma import (subsets, div, printf)
      
      # the middle birthday is on the 24th, and the separation between
      # birthdays is (0, 1, 2, 3, 4, 5, 6, 7), in some order
      for ss in subsets((0, 1, 2, 3, 4, 5, 6, 7), size=len, select="P"):
        # construct the dates
        d5 = 24
        (d4, d6) = (d5 - ss[3], d5 + ss[4])
        (d3, d7) = (d4 - ss[2], d6 + ss[5])
        (d2, d8) = (d3 - ss[1], d7 + ss[6])
        (d1, d9) = (d2 - ss[0], d8 + ss[7])
        if d1 < 1 or d9 > 30: continue
        ds = [ d1, d2, d3, d4, d5, d6, d7, d8, d9]
      
        # John's twin must be born on the 25th
        if 25 not in ds: continue
      
        # sum of the dates of the last 4 is an exact multiple of the sum of
        # the dates of the first four
        x = div(sum(ds[-4:]), sum(ds[:4]))
        if x is None or x < 2: continue
      
        # choose values for the ages (John is 1)
        for ns in subsets((0, 2, 3, 4, 5, 6, 7, 8), size=len, select="P", fn=list):
          # insert 1
          ns.insert(4, 1)
      
          # John's twin (age 0) was born on the 25th
          if ds[ns.index(0)] != 25: continue
      
          # the sum of the ages of the last four is 2/3 the sum of the ages
          # of the first four
          if 3 * sum(ns[-4:]) != 2 * sum(ns[:4]): continue
      
          # [exactly] 2 ages are the same as the date
          if sum(x == y for (x, y) in zip(ds, ns)) != 2: continue
      
          # the sum of the years of birth of the first three is the same as
          # the sum of the years of birth of the last three
          ys = list(1962 - x for x in ns[:5]) + list(1961 - x for x in ns[5:])
          if sum(ys[:3]) != sum(ys[-3:]): continue
      
          # find the 2 grandchildren that share a birthday
          i = ss.index(0)
          # neither can be John
          if i == 3 or i == 4: continue
          # the ages must differ by 2
          if abs(ns[i] - ns[i + 1]) != 2: continue
      
          # output solution
          for (d, n, y) in zip(ds, ns, ys):
            printf("{d:02d} June {y} -> age = {n}{s}", s=(' [*** SOLUTION ***]' if y == 1954 else ''))
          printf()
      

      Solution: The birthday of the grandchild born in 1954 is 11th June.

      The dates of birth and ages are:

      02 June 1960 → age = 2 (age 2 on the 2nd)
      07 June 1955 → age = 7 (age 7 on the 7th)
      11 June 1954 → age = 8 (answer)
      17 June 1958 → age = 4
      24 June 1961 → age = 1 (today, John’s birthday)
      25 June 1961 → age = 0 (John’s twin sister)
      28 June 1958 → ages = 3 & 5 (two granddaughters, exactly 2 years apart)
      30 June 1955 → age = 6

      The program prints two solutions because the granddaughters born on 28th June could appear in either order.

      Like

    • Frits 3:09 pm on 29 June 2022 Permalink | Reply

         
      # dates: A,  B,  C,  D,  E,  F,  G,  H,  I  in order
      # ages : R,  S,  T,  U,  V,  W,  X,  Y,  Z  not necessarily in order
      
      '''
      Notation: XYZ stands for X + Y + Z
      
      The ages are all different, so the twins must be born either side of 
      midnight on the 24th, so John is one of the twins, and the other must
      have a birthday of the 25th. John is the youngest grandson, 
      so his (younger) twin must be a girl.
      
      E = 24, F = 25, V = 1, zero age is either W or X 
      
      After F (25) we can only have intervals 0, 2 and 3 otherwise I exceeds 30
      so I has to be 30 
      A has to be equal to E (24) - intervals 4, 5, 6 and 7, so A = 2
      
      Two children are as old as their dates of birth
      so R = A and S = B
      
      The sum of the ages of the last four is two-thirds of the sum of the
      ages of the first four, sum of all ages is 36, John in the middle is 1
      so we have to split the remaining 35 into a 21 and 14. 
      
      The sum of the years of birth of the first three is equal to the sum of 
      the years of birth of the last three, RST must be equal to XYZ + 3.
      
      2 * RSTU = 3 * WXYZ ==> 2 * RST + 2 * U = 3 * W + 3 * RST - 9
      ==> ST = 2 * U - 3 * W + 7  (using R = 2)
      
      RSTUVWXYZ = 36 
      
      R    [     ST      ]       V       [    XYZ      ]   
      2 +  2 * U - 3 * W + 7 + U + 1 + W + 2 * U - 3 * W + 6 = 36
      5 * (U - W) = 20 ==> U = W + 4
      (U, W) is (4, 0), (7, 3) or (8, 4)
      
      If W is not zero:
        X must be zero leaving (U, W) to be (7, 3) or (8, 4).
        Two daughters with same birthday are exactly two years apart.
        These must be Y and Z (not W as V is male and Y can't be 2)
        W + Y + Z = 14. if W is odd than Y and Z can't be two years apart.
        This leaves W = 4 and Y + Z = 10, only two years apart option for Y and Z
        is 4 and 6. This is impossible as W already is 4. So W = 0 and U = 4.
      '''
      
      # dates: 2,  B,  C,  D, 24, 25,  G,  H, 30  in order
      # ages : 2,  S,  T,  4,  1,  0,  X,  Y,  Z  not necessarily in order
      
      '''
      In order to have after F the intervals 2 and 3 either G or H must be 27 or 28
      so 109 <= FGHI <= 115.
      In order to have intervals 4, 5, 6, 7 we have 36 <= ABCD <= 46
      (using 2, 6, 11, 17 resp. 2, 9, 15, 20 for A, B, C, D). 
      
      So FGHI = 3 * ABCD (using multiplier three) leaving only values 37 and 38
      for ABCD (with FGHI resp. 111 and 114) .
      Using (2, 8, C, D) for (A, B, C, D) we get at least a sum of 39
      then (A, B, C, D) is either (2, 6, C, D) or (2, 7, C, D).
      
      As U = 4 RST must be 17, ST = 15 so R and S must use 7 and 8 
      leaving 3, 5 and 6 for X, Y and Z.
      
      As S is 7 or 8 and B is either 6 or 7 we can deduce R = 7, B = 7, S = 8.
      
      Using (2, 7, 13, 17) for (A, B, C, D) we get at a sum of 39 so 
      (A, B, C, D) is (2, 7, 11, 17). 
      '''
      
      # dates: 2,  7, 11, 17, 24, 25,  G,  H, 30  in order
      # ages : 2,  7,  8,  4,  1,  0,  X,  Y,  Z  not necessarily in order
      
      '''
      As a grandchild born in 1954 can only occur with age 8 and date before 25
      or age 7 and date after 24 we see the answer is 11th June 1954.
      '''
      

      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
%d bloggers like this: