Tagged: by: H. Wright Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 9:42 am on 17 April 2022 Permalink | Reply
    Tags: by: H. Wright   

    An Easter Brain-Teaser: Indoor sports 

    From The Sunday Times, 6th April 1958 [link]

    We know them familiarly as Jennifer, Judith and Jean, but in age order they are the doctor’s wife, the dentist’s widow and the draper’s daughter, and they form the new Committee of our Indoor Sports and Pastimes Club.

    These are the election results, 200 members having each voted for three [different] names:

    Elected:
    Mrs. Battledaw, 148 votes
    Mrs. Shuttlecox, 137 votes
    Mrs. Bowles, 126 votes

    Not elected:
    Mr. D’Artz, 125 votes
    Mr. Snewker, 64 votes

    Total votes cast:
    600 votes

    Those who voted for both Jean and Judith were the same in number as those who didn’t vote for the doctor’s wife and if even one of Snewker’s supporters had voted for D’Artz he might have gained the third place. Jean is more interested in Mr. Bowles than in her own husband, who is sorry the draper’s daughter didn’t come top.

    Who are Jennifer, Judith and Jean?

    This is one of the occasional Holiday Brain Teasers published in The Sunday Times prior to the start of numbered Teasers in 1961. A prize of £5 was offered.

    [teaser-1958-04-06] [teaser-unnumbered]

     
    • Jim Randell's avatar

      Jim Randell 9:43 am on 17 April 2022 Permalink | Reply

      There are 5 candidates (let’s number them 1, 2, 3, 4, 5), and each member votes for three different candidates, so possible voting patterns are:

      a = (1, 2, 3)
      b = (1, 2, 4)
      c = (1, 2, 5)
      d = (1, 3, 4)
      e = (1, 3, 5)
      f = (1, 4, 5)
      g = (2, 3, 4)
      h = (2, 3, 5)
      i = (2, 4, 5)
      j = (3, 4, 5)

      If we suppose a, …, j are the numbers who voted for their respective patterns, then their sum is 200.

      a + b + c + d + e + f + g + h + i + j = 200

      And from the votes cast (assuming the numbers are the order that the candidates finished in), we have:

      a + b + c + d + e + f = 148
      a + b + c + g + h + i = 137
      a + d + e + g + h + j = 126
      b + d + f + g + i + j = 125
      c + e + f + h + i + j = 64

      We are told “if even one of Snewker’s [5] supporters had voted for D’Artz [4] he might have gained the third place”, which implies that no-one voted for both 4 and 5, so:

      f = 0
      i = 0
      j = 0

      Hence:

      a + b + c + d + e = 148
      a + b + c + g + h = 137
      a + d + e + g + h = 126
      b + d + g = 125
      c + e + h = 64

      We can use one of these equations to select seed values (I used: c + e + h = 64), and then determine the remaining values using the remaining equations, and verify that they are non-negative integers, and that the additional conditions hold.

      The following Python program runs in 241ms.

      Run: [ @replit ]

      from enigma import (Matrix, decompose, as_int, subsets, multiset, printf)
      
      # record solutions, as: ((jen, jud, jea), (doc, den, dra))
      ss = multiset()
      
      # initial values
      f = i = j = 0
      
      # consider values for c, e, h
      for (c, e, h) in decompose(64, 3, increasing=0, sep=0, min_v=0):
      
        # solve for the remaining values
        eqs = [
          # a  b  d  g = k
          ((1, 1, 1, 0), 148 - c - e),
          ((1, 1, 0, 1), 137 - c - h),
          ((1, 0, 1, 1), 126 - e - h),
          ((0, 1, 1, 1), 125),
        ]
      
        # look for non-negative integers
        try:
          (a, b, d, g) = Matrix.linear(eqs, valid=(lambda x: as_int(x, "0+")))
        except ValueError:
          continue
      
        # consider positions by names
        for (jen, jud, jea) in subsets((1, 2, 3), size=len, select="P"):
          # Jean is not Mrs Bowles
          if jea == 3: continue
          # v1 = votes for both Jean and Judith
          v1 = { 1: a + g + h, 2: a + d + e, 3: a + b + c }[jen]
      
          # consider related occupations by position
          for (doc, den, dra) in subsets((1, 2, 3), size=len, select="P"):
            # Jean's husband was not the dentist
            if den == jea: continue
            # Draper's daughter didn't come top
            if dra == 1: continue
            # v2 = didn't vote for doctor's wife
            v2 = { 1: g + h + i + j, 2: d + e + f + j, 3: b + c + f + i }[doc]
            if v1 != v2: continue
            # record this solution
            ss.add(((jen, jud, jea), (doc, den, dra)))
      
      # output solutions
      for (((jen, jud, jea), (doc, den, dra)), n) in ss.most_common():
        name = { 1: "Battledaw", 2: "Shuttlecox", 3: "Bowles" }
        rel = { doc: "doctor", den: "dentist", dra: "draper" }
        printf("[{n} solutions]")
        printf("-> Jennifer = Mrs {n} [{r}]", n=name[jen], r=rel[jen])
        printf("-> Judith = Mrs {n} [{r}]", n=name[jud], r=rel[jud])
        printf("-> Jean = Mrs {n} [{r}]", n=name[jea], r=rel[jea])
        printf()
      

      Solution: Jennifer is Mrs Battledaw, the dentist’s widow (1st); Judith is Mrs Bowles, the draper’s daughter (3rd); Jean is Mrs Shuttlecox, the doctor’s wife (2nd).

      There are many distributions of votes, but they all satisfy:

      a = 11
      b = 10..74
      c = 74 − b
      d = 0..63
      e = 63 − e
      f = 0
      g = 125 − (b + d)
      h = (b + d) − 73
      i = 0
      j = 0

      And lead to the solution given above.

      Like

    • John+Crabtree's avatar

      John+Crabtree 6:44 pm on 18 April 2022 Permalink | Reply

      Nobody votes for both Dr. A and Mr. S, meaning that 11 people vote for all three women,
      It can then be shown that 84 people vote for both Mrs. Ba. and Mrs. Sh, 74 people for both Mrs. Ba. and Mrs. Bo, and 63 people for both Mrs. Sh. and Mrs. Bo.

      The Doctor’s wife must get 137 or 126 votes, and so must the Draper’s daughter, who is not in first place. And so the Dentist’s widow must get 148 votes, and cannot be Jean, who is married.
      Jean cannot be Mrs. Bowles and so cannot get 126 votes, and so must get 137 votes.
      Then Judith must get 126 votes, and so Jean is the Doctor’s wife, Judith is the Draper’s daughter, and Jennifer is the Dentist’s widow.

      Like

  • Unknown's avatar

    Jim Randell 7:16 am on 25 June 2020 Permalink | Reply
    Tags: by: H. Wright   

    Brain-Teaser 1: Tall story 

    From The Sunday Times, 26th February 1961 [link]

    “We’re a biggish family in more ways than one”, said Jeremy. “Five, including triplets, and three of us the same height. I’m 6 ft. and aged 72; Jim is three inches taller than John and three years older; and John and Julian’s combined heights are 5 ft. 11 in. more than Joe’s and their combined ages 71 years more than his. Our aggregate height in inches equals our aggregate age in years, but no one’s age in years equals Joe’s height in inches”.

    What were the name, age and height of the tallest of the triplets?

    This was the first of the regular Teaser puzzles published in The Sunday Times. It was accompanied by the following introduction:

    Brain-Teasers: a Weekly Feature

    Great numbers of our readers have found entertainment and interest in the Brain-Teasers, or mathematical problems, which we have published from time to time, usually at holiday week-ends. Now we intend to make them a weekly feature of The Sunday Times.

    Readers themselves have supplied many of the best of the problems in the past, and we invite them to continue to do so. A fee of £10 will be paid for each problem accepted.

    Problems should fulfil the following conditions: Both the problem and the solution must be expressible in reasonably brief compass. No advanced or specialist mathematical techniques should be necessary. Solutions should be unique, or otherwise admit of no uncertainty in judging. Problems must be original. Diagrams are admissible if they are not too complicated.

    The problem below is the invention of a reader who observes: “Any who are stumped by it after the expiry of an hour should feel cause for concern”.

    A prize of £3 was offered.

    [teaser1]

     
    • Jim Randell's avatar

      Jim Randell 7:17 am on 25 June 2020 Permalink | Reply

      We can associate values (A, B, C, D, E) with (Jez, Jim, Jon, Jul, Joe), that correspond to either their heights in inches or their ages in years, both give rise to the same set of equations:

      A = 72
      B = C + 3
      C + D = E + 71
      x = y = z

      where (x, y, z) are some three of (A, B, C, D, E).

      This gives us a set of 5 simultaneous equations in 5 variables.

      This Python program finds solutions to these equations (using the [[ Matrix.linear() ]] solver from the enigma.py library), groups the solutions by the sum of the set of values, and then looks for two sets with the same sum (one set for the ages, and another set for the height) that satisfy the condition that Joe’s height does not appear in the set of ages.

      It runs in 55ms.

      Run: [ @replit ]

      from enigma import (Matrix, subsets, as_int, multiset, group, printf)
      
      # labels for the people involved
      # A = Jez, B = Jim, C = Jon, D = Jul, E = Joe
      labels = (A, B, C, D, E) = (0, 1, 2, 3, 4)
      
      # solve equations specified as: (ps, ms, k)
      # for integer solutions
      def solve(eqs):
        (A, B) = (list(), list())
        for (ps, ms, k) in eqs:
          eq = [0] * 5
          for (i, n) in multiset.from_seq(ps).items(): eq[i] += n
          for (i, n) in multiset.from_seq(ms).items(): eq[i] -= n
          A.append(eq)
          B.append(k)
        try:
          # find values that are positive integers
          return Matrix.linear(A, B, valid=(lambda x: as_int(x, include='+')))
        except ValueError:
          return
      
      # find values that satisfy the equations
      def generate():
        # choose the three with the same value
        for (x, y, z) in subsets(labels, size=3):
          # solve the equations
          r = solve([
            ([A], [], 72), # A = 72
            ([B], [C], 3), # B = C + 3
            ([C, D], [E], 71), # C + D = E + 71
            ([x], [y], 0), # x = y
            ([y], [z], 0), # y = z
          ])
          if r is None: continue
          # check there is a set of triplets
          if not (3 in multiset.from_seq(r).values()): continue
          # return candidate solutions
          yield r
      
      # group sets of solutions by the sum of the values
      d = group(generate(), by=sum)
      
      # consider values for the sum
      for (t, rs) in d.items():
        # choose two sets of values for the ages and heights
        for (age, height) in subsets(rs, size=2, select="M"):
          # no one's age is the same as Joe's height
          if height[E] in age: continue
          for (n, a, h) in zip("Jez Jim Jon Jul Joe".split(), age, height):
            printf("{n}: age {a} yr, height {h} in")
          printf()
      

      Solution: Jim is the tallest of the triplets. His age is 72, his height is 6ft 2in.

      The complete characteristics are:

      Jez: age 72 yr, height 72 in
      Jim: age 72 yr, height 74 in
      Jon: age 69 yr, height 71 in
      Jul: age 74 yr, height 71 in
      Joe: age 72 yr, height 71 in

      So: Jeremy, Jim, Joe are the triplets (same age), and: John, Julian, Joe are the same height.

      There are 7 ways to solve the equations, but there is only one pair that has the same sum, and this gives rise to the solution.

      Like

    • GeoffR's avatar

      GeoffR 4:10 pm on 25 June 2020 Permalink | Reply

      I found three solutions in MinZinc.

      The first solution was invaiid as there was no single maximum height.

      The second solution was the same as Jim’s solution above.

      There appears to be another solution, which gives the maximum height of Jim as 6ft 3 in, with an age of 75 years. If the puzzle had stated that age and height could not be the same, then this last solution could be ruled out – it appears to conform to the stated conditions in the puzzle.

      
      % A Solution in MiniZinc
      include "globals.mzn";
       
      var 10..99: JezAge; var 10..99: JimAge; var 10..99: JonAge; 
      var 10..99: JulAge; var 10..99: JoeAge; 
      
      var 50..80: JezHt; var 50..80: JimHt; var 50..80: JonHt; 
      var 50..80: JulHt; var 50..80: JoeHt; 
      
      % Three of us the same height
      % (A,B,C,D,E) = (Jez, Jim, Jon, Jul, Joe)
      constraint (JezHt == JimHt /\ JimHt == JonHt)  % ABC
      \/ (JezHt == JimHt /\ JimHt == JulHt)   % ABD
      \/ (JezHt == JimHt /\ JimHt == JoeHt)   % ABE
      \/ (JezHt == JonHt /\ JonHt == JulHt)   % ACD
      \/ (JezHt == JonHt /\ JonHt == JoeHt)   % ACE
      \/ (JezHt == JulHt /\ JulHt == JoeHt)   % ADE
      \/ (JimHt == JonHt /\ JonHt == JulHt)   % BCD
      \/ (JimHt == JonHt /\ JonHt == JoeHt)   % BCE
      \/ (JimHt == JulHt /\ JulHt == JoeHt)   % BDE
      \/ (JonHt == JulHt /\ JulHt == JoeHt);  % CDE
      
      % Three of us the same age(triplets)
      constraint (JezAge == JimAge /\ JimAge == JonAge)  % ABC
      \/ (JezAge == JimAge /\ JimAge == JulAge)   % ABD
      \/ (JezAge == JimAge /\ JimAge == JoeAge)   % ABE
      \/ (JezAge == JonAge /\ JonAge == JulAge)   % ACD
      \/ (JezAge == JonAge /\ JonAge == JoeAge)   % ACE
      \/ (JezAge == JulAge /\ JulAge == JoeAge)   % ADE
      \/ (JimAge == JonAge /\ JonAge == JulAge)   % BCD
      \/ (JimAge == JonAge /\ JonAge == JoeAge)   % BCE
      \/ (JimAge == JulAge /\ JulAge == JoeAge)   % BDE
      \/ (JonAge == JulAge /\ JulAge == JoeAge);  % CDE
      
      % Jez is 6 ft. and aged 72
      constraint JezHt == 72 /\ JezAge == 72;
      
      % Jim is three inches taller than John and three years older
      constraint JimHt - 3 == JonHt /\ JimAge - 3 == JonAge;
      
      %  John and Julian’s combined heights are 5 ft. 11 in. more than Joe’s
      %  and their combined ages 71 years more than his
      constraint JonHt + JulHt - 71 == JoeHt;  
      constraint JonAge + JulAge - 71 == JoeAge;
      
      % Our aggregate height in inches equals our aggregate age in years
      constraint  JimHt + JezHt + JulHt + JonHt + JoeHt 
      == JimAge + JezAge + JulAge  + JonAge + JoeAge;
      
      % No one’s age in years equals Joe’s height in inches
      constraint JoeHt != JezAge /\ JoeHt != JimAge
      /\ JoeHt != JonAge /\ JoeHt != JulAge;
      
      solve satisfy;
      
      output ["Ages: " ++ show([JezAge, JimAge, JonAge, JulAge, JoeAge])]++
      ["\nHeights: " ++ show([JezHt, JimHt, JonHt, JulHt, JoeHt])];
      
      %           Jez Jim Jon Jul Joe
      % Ages:    [72, 72, 69, 72, 70]  << no single tallest member 
      % Heights: [72, 72, 69, 72, 70]  << Therefore, an invalid solution
      % ----------
      % Ages:    [72, 72, 69, 74, 72]  <<  Jim is tallest member at 6 ft. 2 in.
      % Heights: [72, 74, 71, 71, 71]  <<  with an age of 72 years
      % ----------
      % Ages:    [72, 75, 72, 72, 73]  << Jim is tallest member at 6 ft. 3 in.
      % Heights: [72, 75, 72, 72, 73]  <<  with an age of 75 years
      % ----------
      % ==========
      
      
      

      Like

      • Jim Randell's avatar

        Jim Randell 4:15 pm on 25 June 2020 Permalink | Reply

        @Geoff: The condition “no one’s age in years equals Joe’s height in inches”, means that Joe’s age is not equal to Joe’s height. So this disposes of two of your solutions. (And effectively means that the same set of solutions cannot be used for both ages and heights).

        Like

    • GeoffR's avatar

      GeoffR 4:38 pm on 25 June 2020 Permalink | Reply

      @Jim: Fair point. I was interpreting only other people’s ages only could not be equal to Joe’s height. It could have been more clearly stated that this condition also applied to Joe himself!

      Like

    • Frits's avatar

      Frits 3:51 pm on 28 July 2020 Permalink | Reply

      from enigma import SubstitutedExpression, icount #, multiset
      
      # suppose Jez not part of three --> Also either Jon or Jim not part of three 
      #   --> Joe and Jul part of three --> Jez = 72, Jon = 71, Jim 74, Joe = 71, Jul = 71 or
      #       (Jon has to be 71)            Jez = 72, Jon = 71, Jim 74, Joe = 74, Jul = 74 
      # suppose Jez part of three 
      #   --> if both Jim and Jon not part of three --> Jon = 71, Jim = 74
      #       else Jim or Jon is 72 --> Jez = 72, Jon = 72, Jim 75, Jul == Joe - 1 or
      #                                 Jez = 72, Jon = 69, Jim 72, Jul == Joe + 2
      # --> Joe 70-74
      # --> Jim 72,74,75
      # --> Jul 71,72,74
      # --> Jon 69,71,72
          
      
      # the alphametic puzzle
      p = SubstitutedExpression(
        [
          #  Jez Age    Joe Age    Jim Age    Jul Age    Jon Age
          #    AB         CD         EF         GH         IJ     
          #  Jez Hght   Joe Hght   Jim Hght   Jul Hght   Jon Hght
          #    KL         MN         OP         QR         ST   
          
          # Jez is 6 ft. and aged 72
          "AB = 72", "KL = 72",
        
          # Jim is three inches taller than John and three years older
          "IJ + 3 == EF" ,"ST + 3 = OP",
         
          # Jul and Jon's combined heights are 5 ft 11 in more than Joe's
          # and their combined ages 71 years more than his
          "QR + ST == MN + 71", "GH + IJ == CD + 71",
          
          # aggregate height in inches equals aggregate age in years
          "AB + CD + EF + GH + IJ == KL + MN + OP + QR + ST",
          
          # No one's age in years equals Joe's height in inches
          "AB != MN", "CD != MN", "EF != MN", "GH != MN", "IJ != MN",
          
          # Three have the same age, three have same height
          "icount([AB, CD, EF, GH, IJ], (lambda d: v([AB, CD, EF, GH, IJ]) == d)) == 3",
          "icount([KL, MN, OP, QR, ST], (lambda d: v([KL, MN, OP, QR, ST]) == d)) == 3",
          #"sorted(multiset.from_seq([AB, CD, EF, GH, IJ]).values()) == [1, 1, 3]",
          #"sorted(multiset.from_seq([KL, MN, OP, QR, ST]).values()) == [1, 1, 3]",
          
          # ----------------------------
          # try to speed up 
          # ----------------------------
          
          #"CD in ([70,71,72,73,74])",
          #"EF in ([72,74,75])",
          #"GH in ([71,72,74])",
          #"IJ in ([69,71,72])",
          
          #"MN in ([70,71,72,73,74])",
          #"OP in ([72,74,75])",
          #"QR in ([71,72,74])",
          #"ST in ([69,71,72])",
        ],
        distinct="", 
        code="v = lambda x: max(x,key=x.count)",
        answer="AB, CD, EF, GH, IJ, KL, MN, OP, QR, ST"
      )      
                                
      # Print answers
      
      for (_, ans) in p.solve(verbose=0): 
         print("        Age        |       Height") 
         print("Jez Joe Jim Jul Jon Jez Joe Jim Jul Jon")
         print(ans)
         
      # Output:   
      #         Age        |       Height
      # Jez Joe Jim Jul Jon Jez Joe Jim Jul Jon
      # (72, 72, 72, 74, 69, 72, 71, 74, 71, 71) 
      

      Remarks regarding speed:

      "IJ + 3 == EF" ,"ST + 3 = OP",  # Approx 1.3 secs
      "IJ + 3 = EF" ,"ST + 3 == OP",  # Approx 14 secs
      "IJ + 3 = EF" ,"ST + 3 = OP",   # Approx 14 secs
      "IJ + 3 == EF" ,"ST + 3 == OP", # SyntaxError: too many statically nested blocks
      

      The speed up logic I had to invent before I discovered the “IJ + 3 == EF” ,”ST + 3 = OP” equations.
      In theory the multiset equations are too restrictive

      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