Tagged: flawed Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 7:49 am on 17 September 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 1973: Straw store 

    From The Sunday Times, 9th July 2000 [link]

    Farmer Fermat has more straw than he can safely stack on his usual rectangular storage area. So he extends the shorter sides of the area to equal the longer sides, thereby forming a square. Alongside he adds another square area, whose side is equal to the shorter side of the original rectangle. The total area of the two squares together is 243 square feet larger than the original rectangle.

    He can now stack straw on each square, up to a height equal to the length of the side of each square, effectively forming two cubes, and the total volume in cubic feet is a perfect cube.

    What was the perimeter of the original rectangle?

    [teaser1973]

     
    • Jim Randell's avatar

      Jim Randell 7:50 am on 17 September 2019 Permalink | Reply

      As presented this puzzle has multiple solutions. However if the perimeter of the original rectangle is required to be a whole number of feet, then only one of the solutions remains.

      This Python program finds all the solutions to the puzzle numerically using the [[ find_zero() ]] function from the enigma.py library. It runs in 63ms.

      Run: [ @replit ]

      from enigma import (irange, cb, cbrt, sq, find_zero, catch, printf)
      
      # consider values for t, where T = t^3 is the total volume
      for t in irange(1, 100):
        T = cb(t)
      
        # calculate y (for x in [0, t])
        def Y(x):
          return cbrt(T - cb(x))
      
        # how close is x^2 + y^2 - xy to 243?
        def f(x):
          y = Y(x)
          return abs((sq(x) + sq(y) - x * y) - 243)
      
        # find a zero for f
        r = catch(find_zero, f, 0, cbrt(0.5 * T))
        if r is None: continue
        x = r.v
        y = Y(x)
        p = 2 * (x + y)
      
        # output solution
        printf("t={t}: x={x:.3f}, y={y:.3f}, p={p:.3f}")
      

      Solution: The (integer) perimeter of the original rectangle was 48 feet.

      Allowing non-integer solutions for the perimeter we get four solutions:

      t=16: x=0.857, y=15.999, p=33.712
      t=17: x=3.258, y=16.960, p=40.436
      t=18: x=6.255, y=17.745, p=48.000
      t=19: x=10.291, y=17.935, p=56.453

      Graphically we get a solution when the ellipse x² + y² − xy = 243 intersects the curve x³ + y³ = t³ for integer values of t.

      For positive x and y we get solutions for t = 16, 17, 18, 19, as shown in the graph below:

      The original rectangle has sides of length x and y, so the perimeter of the original rectangle is 2(x + y). Only t=18 gives an integer value for the perimeter (although the values for x and y are not integers). In this case the exact values are: x, y = 12 ± √33.

      Like

      • Jim Randell's avatar

        Jim Randell 8:39 am on 19 September 2019 Permalink | Reply

        Here is an analytical solution.

        Given the equations:

        x³ + y³ = t³
        x² + y² − xy = 243

        If we consider the product (x + y)(x² + y² − xy) we have:

        (x + y)(x² + y² − xy) = x³ + y³ = t³
        (x + y) = t³ / 243

        We also have:

        (x + y)² = (x² + y²) + 2xy
        (x + y)² = (243 + xy) + 2xy
        (x + y)² = 243 + 3xy
        xy = (x + y)² / 3 − 81

        So for a given value of t we can determine values for x + y and xy, say:

        x + y = a
        xy = b

        These have positive real solutions for x and y when a² ≥ 4b and b ≥ 0

        a² ≥ 4b
        (x + y)² ≥ 4xy
        (x + y)² ≥ (4/3)(x + y)² − 324
        (x + y)² ≤ 973
        (x + y) ≤ √973
        t³ ≤ 243 × √973
        t ≤ 19.643…

        b ≥ 0
        (x + y)² / 3 − 81 ≥ 0
        (x + y)² ≥ 243
        (x + y) ≥ √243
        t³ ≥ 243 × √243
        t ≥ 15.588…

        So t is in the range 16 to 19. And the required perimeter is given by p = 2(x + y) = 2t³ / 243.

        We can consider the 4 candidate values manually and look for an integer solution, or use a short program:

        Run: [ @replit ]

        from enigma import (irange, cb, div, printf)
        
        for t in irange(16, 19):
          p = div(2 * cb(t), 243)
          if p is None: continue
          printf("t={t}: p={p}")
        

        Like

  • Unknown's avatar

    Jim Randell 8:29 am on 13 September 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 2783: Old boys’ banquet 

    From The Sunday Times, 24th January 2016 [link] [link]

    George and Martha have arranged the seating plan for the annual Old Boys banquet; it involves a number of tables, each seating 50 diners. More than half the Old Boys are bringing one female guest each and the rest are coming alone. Martha wrote down three numbers, namely the number of Old Boys bringing a guest, the number of Old Boys coming alone, and the total number of Old Boys coming. George noted that the three numbers between them used each of the digits 0 to 9 exactly once.

    How many Old Boys are bringing a guest, and how many are coming alone?

    [teaser2783]

     
    • Jim Randell's avatar

      Jim Randell 8:30 am on 13 September 2019 Permalink | Reply

      If s is the number of old boys without guests and g is the number with guests, then we have a pandigital sum of the form:

      s + g = b

      where s < g.

      Altogether there are 10 digits used so, alphametically, the sum is one of:

      AB + CDEF = GHIJ
      ABC + DEF = GHIJ

      This Python program uses the [[ SubstitutedSum() ]] solver from the enigma.py library to examine solutions to both sums. It runs in 277ms.

      Run: [ @repl.it ]

      from enigma import SubstitutedSum, div, printf
      
      # solve the pandigital sum
      digits = 'ABCDEFGHIJ'
      for k in (2, 3):
        (x, y, z) = (digits[0:k], digits[k:6], digits[6:])
        p = SubstitutedSum([x, y], z)
        for s in p.solve():
          # turn the solution into numbers
          (s, g, b) = (int(p.substitute(s, w)) for w in (x, y, z))
          # more than half the old boys have guests
          if not (g > s): continue
          # so the total number of people is...
          t = b + g
          # and the number of tables is...
          n = div(t, 50)
          if n is None: continue
        
          printf("s={s} g={g} boys={b}, people={t} tables={n}")
      

      Solution: There are four possible solutions:

      26 without guests, 4987 with guests; 5013 total boys, 10000 total people, 200 tables
      74 without guests, 5938 with guests; 6012 total boys, 11950 total people, 239 tables
      86 without guests, 1957 with guests; 2043 total boys, 4000 total people, 80 tables
      346 without guests, 752 with guests; 1098 total boys, 1850 total people, 37 tables

      I suspect the setter intended the final solution to be the correct answer, which is the only solution where the pandigital sum is of the form: ABC + DEF = GHIJ.

      A suitable upper limit on the total number of old boys, total number of people, or number of tables would eliminate the other solutions.

      However if we change the condition in the puzzle text to:

      More than half the Old Boys are coming alone and the rest are bringing one female guest each.

      (i.e. we require s > g).

      Then there is only a single solution to the puzzle:

      746 without guests, 352 with guests; 1098 total boys, 1450 total people, 29 tables

      Reversing the inequality at line 12 of the program will give this solution.

      Like

    • GeoffR's avatar

      GeoffR 1:59 pm on 14 September 2019 Permalink | Reply

      % A Solution in MiniZinc
      include "globals.mzn"; 
      
      var 0..9: a; var 0..9: b; var 0..9: c; var 0..9: d; var 0..9: e;
      var 0..9: f; var 0..9: g; var 0..9: h; var 0..9: i; var 0..9: j;
      
      % Assume boys/boys with guest/total boys are in ratio 3:3:4
      var 100..999: abc;     % boys with guest
      var 100..999: def;     % boys alone
      var 1000..2000: ghij;  % total boys
      var 0..250: tables;    % total tables
      
      % All ten digits are used exactly once
      constraint alldifferent([a,b,c,d,e,f,g,h,i,j]) 
                 /\ a > 0 /\ d > 0 /\ g > 0;
      
      constraint  abc = 100*a + 10*b + c
               /\ def = 100*d + 10*e + f
               /\ ghij = 1000*g + 100*h + 10*i + j ;
      
      % More than half the boys brought a female guest
      constraint abc > ghij div 2;
      
      constraint abc + def == ghij;
      
      constraint tables * 50 == abc * 2 + def;
      
      solve satisfy;
      
      output [" Boys with a guest: " ++ show(abc) ++ "\n" ++
              " Boys on their own: " ++ show(def) ++ "\n" ++
              " Total boys: " ++ show(ghij) ++ "\n" ++
              " Tables: " ++ show(tables)];  
      
      % Boys with a guest: 752
      % Boys on their own: 346
      % Total boys: 1098
      % Tables: 37
      % ----------
      % ==========
      
      

      Like

  • Unknown's avatar

    Jim Randell 9:14 am on 7 August 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 2894: Time duality 

    From The Sunday Times, 11th March 2018 [link] [link]

    After a good breakfast, Seb decided on 40 winks. He noted the time on his digital clock as he dozed off. When he woke up a little later that day, not fully alert, he saw the display reflected in a mirror and was amazed by how long he seemed to have slept. This was in fact 10 times the length of his nap. Next day, a similar thing happened: he fell asleep at the same time and slept a little less, but when he woke, the mirror led him to believe he had slept for 20 times as long as he had. (All times were whole numbers of minutes after midnight).

    At what time did he fall asleep?

    [teaser2894]

     
    • Jim Randell's avatar

      Jim Randell 9:16 am on 7 August 2019 Permalink | Reply

      We can find multiple solutions to this puzzle, depending on how the clock works.

      The program examines the following three scenarios for a digital clock consisting of standard 7-segment digits, where the digits 0, 1 and 8 appear the same when mirrored, and the digits 2 and 5 appear as each other when mirrored.

      Scenario 1: 24 hour clock, always displays 4 digits, reads from 00:00 – 23:59.

      Scenario 2: 24 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 0:00 – 23:59.

      Scenario 3: 12 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 12:00 – 11:59.

      It runs in 125ms.

      Run: [ @replit ]

      from enigma import (defaultdict, cproduct, arg, irange, nsplit, div, sprintf, printf)
      
      # digit reflections
      X = None
      #           0  1  2  3  4  5  6  7  8  9
      reflect = [ 0, 1, 5, X, X, 2, X, X, 8, X ] 
      
      # format time t as hh:mm
      def fmt(t, hours=24):
        k = 0
        while t < 0:
          k -= 1
          t += hours * 60
        while t > hours * 60:
          k += 1
          t -= hours * 60
        (h, m) = divmod(t, 60)
        return sprintf("{h:02d}:{m:02d} [{k:+d}]")
      
      # solve using digits function <digits>
      def solve(digits, hours=24):
        # record results by start time (in minutes), 10x or 20x
        rs = defaultdict(lambda: defaultdict(list))
      
        # map display digits to possible times
        m = defaultdict(list)
        for t in irange(0, 24 * 60 - 1):
          m[digits(t)].append(t)
      
        # find sequences that have a reverse sequence
        for (s, t1s) in m.items():
          r = tuple(reflect[d] for d in s[::-1])    
          if None in r or r == s: continue
          if r in m:
            t2s = m[r]
      
            for (t1, t2) in cproduct([t1s, t2s]):
              if t1 == t2: continue
              while t2 < t1: t2 += 24 * 60
              d = t2 - t1
      
              # find differences that give 9x or 19y
              x = div(d, 9)
              if x:
                t0 = t1 - x
                printf("[{t1} | {t2} = {d} min (9x {x}m), t0={t0}]", t1=fmt(t1, hours), t2=fmt(t2, hours), t0=fmt(t0, hours))
                rs[t0][10].append((t1, t2))
              y = div(d, 19)
              if y:
                t0 = t1 - y
                printf("[{t1} | {t2} = {d} min (19x {y}m), t0={t0}]", t1=fmt(t1, hours), t2=fmt(t2, hours), t0=fmt(t0, hours))
                rs[t0][20].append((t1, t2))
      
        # output solutions
        for (t0, d) in rs.items():
          for ((t1a, t2a), (t1b, t2b)) in cproduct([d[10], d[20]]):
            if t1b < t1a:
              (ft0, ft1a, ft2a, ft1b, ft2b) = (fmt(x, hours) for x in (t0, t1a, t2a, t1b, t2b))
              printf("10x = {ft0} - {ft1a} | {ft2a} / 20x = {ft0} - {ft1b} | {ft2b}")
      
      # digits displayed for time t in the different scenarios:
      
      # [1] four digits, 24 hours: 00:00 - 23:59
      def digits1(t):
        (h, m) = divmod(t, 60)
        return nsplit(h % 24, 2) + nsplit(m, 2)
      
      # [2] three or four digits, 24 hours: 0:00 - 23:59, no clear separator
      def digits2(t):
        (h, m) = divmod(t, 60)
        return nsplit(h % 24) + nsplit(m, 2)
      
      # [3] three or four digits, 12 hours: 0:00 - 11:59, no clear separator
      def digits3(t):
        (h, m) = divmod(t, 60)
        return nsplit(h % 12 or 12) + nsplit(m, 2)
      
      
      types = {
        '1': [ digits1, "[type 1] 00:00 - 23:59", 24 ],
        '2': [ digits2, "[type 2] 0:00 - 23:59", 24 ],
        '3': [ digits3, "[type 3] 12:00 - 11:59", 12 ],
      }
      
      cmd = arg("123", 0)
      
      for k in sorted(types.keys()):
        if k not in cmd: continue
        (fn, t, h) = types[k]
        printf("{t}")
        solve(fn, hours=h)
        printf()
      

      We find the following solutions:

      Scenario 1: 24 hour clock, always displays 4 digits, reads from 00:00 – 23:59.

      This is probably the most reasonable expectation of the clock’s behaviour without further explanation.

      Day 1: The nap starts at 09:41 and finishes after 74m at 10:55. The mirrored display reads 22:01 corresponding to a nap of 740m (= 10×74m).
      Day 2: The nap starts at 09:41 and finishes after 34m at 10:15. The mirrored display reads 21:01 corresponding to a nap of 680m (= 20×34m).

      Day 1: The nap starts at 09:21 and finishes after 119m at 11:20. The mirrored display reads 05:11 corresponding to a nap of 1190m (= 10×119m).
      Day 2: The nap starts at 09:21 and finishes after 59m at 10:20. The mirrored display reads 05:01 corresponding to a nap of 1180m (= 20×59m).

      But in both these solutions the second nap is less than half the length of the first nap, so it is a bit odd to say he slept “a little less” than the previous day.

      Scenario 2: 24 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 0:00 – 23:59.

      The 09:41 nap works the same, but the 09:21 nap does not as 10:20 when mirrored does not correspond to a displayable time.

      Day 1: The nap starts at 09:41 and finishes after 74m at 10:55. The mirrored display reads 22:01 corresponding to a nap of 740m (= 10×74m).
      Day 2: The nap starts at 09:41 and finishes after 34m at 10:15. The mirrored display reads 21:01 corresponding to a nap of 680m (= 20×34m).

      This scenario has a unique solution, but the problem remains that the second nap is less than half the length of the first nap.

      Scenario 3: 12 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 12:00 – 11:59.

      Day 1: The nap starts at 07:18 and finishes after 64m at 08:22. The mirrored display reads “558” corresponding to 17:58 and a nap of 640m (= 10×64m).
      Day 2: The nap starts at 07:18 and finished after 57m at 08:15. The mirrored display reads “218” corresponding to 02:18 and a nap of 1140m (= 20×57m).

      And as it is a 12 hour clock this all works shifted on 12 hours, although perhaps 7:18pm is a little late to be having breakfast.

      The problem here is that on day two when seeing the clock reading 2:18 Seb would probably think he had slept for 7 hours, not for 19 hours. However this is the best solution for sleeping “a little less” on the second day, and the puzzle text does say Seb was not fully alert when he read the clock.


      Out of all these scenarios the one that best fits the puzzle text is Scenario 3:

      On the first day, Seb has an early breakfast, and starts his snooze at 7:18am, and wakes up at 8:22am, having slept for 64m, but reads the time as 5:58, and believes he has slept until 5:58pm, which is 640m.

      On the second day, Seb again starts his snooze at 7:18am, and wakes at 8:15am, having slept for 57m (which is only 7m shorter than the previous day). He reads the time as 2:18, and believes he has slept until 2:18am the following day, which is 1140m.

      This gives us a solution to the puzzle that Seb fell asleep on both days at 7:18am.

      It is possible that the phrase “all times were whole numbers of minutes after midnight”, is meant to indicate that all the times mentioned (including the false mirrored times) are all supposed to fall within the same 24 hour day, in which case the 9:41am solution in Scenario 1 or Scenario 2 remain, and give a unique solution of 9:41am. This may be the setters intended solution.

      But as there are multiple possible answers I have marked this puzzle as “flawed“.


      The published solution is: “09:41am”.

      Liked by 1 person

  • Unknown's avatar

    Jim Randell 9:52 am on 4 July 2019 Permalink | Reply
    Tags: , flawed   

    Brain-Teaser 484: [Family ages] 

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

    The total ages of my children, all of single birth, exactly equal my own age. On the same day next year they will exactly equal my husbands age.

    At present my husband’s age is divisible by the age of only one child, but in one year’s time it will be divisible by the separate ages of three children and also by the number of children in the family, while my own age will be divisible by the age of one child only.

    During the year ahead, on just one day in May, my husband’s age will be divisible by that of my eldest child.

    What are the children’s ages?

    Note: This puzzle is flawed, as there is not a single solution. A note was published with Brain-Teaser 485 saying that as there are three solutions no prize can be awarded.

    This puzzle was originally published with no title.

    [teaser484]

     
    • Jim Randell's avatar

      Jim Randell 9:54 am on 4 July 2019 Permalink | Reply

      I found many solutions to this puzzle, not just the 3 mentioned when Brain-Teaser 485 was published.

      The simplest solution was with 4 children with ages: 1, 2, 11, 18. This gives:

      The wife’s age is 32, the husband’s age is 35.

      Only 1 divides into 35, but next year (when the children are 2, 3, 12, 19 and the husband is 36) three of the children ages (2, 3, 12) will divide in 36.

      And the wife will be 33, and 3 divides into this.

      During May the eldest child’s age (18) does not divide into the husband’s age (35), until the husband’s birthday, when he is 36. The next day is the eldest child’s birthday, who become 19, which not divide the husband’s age.

      The problem with this solution is that at the time of birth of the eldest child the wife would be 14 and the husband 17. While not impossible, it’s probably not what the setter had in mind, so we’ll stick with more conventional scenarios.

      To make a version of the puzzle with a single solution I added a couple of extra conditions.

      Firstly I strengthened the “all of single birth” condition to the children all having different ages (in years), and restricted the current ages of the children to be between 2 and 16.

      This gets me down to 5 solutions (one with 5 children, and four with 7 children). Adding a further reasonable conditions such as “the husband and wife are both aged less than 50” or “the wife was in her twenties at the time of the birth of the eldest child” can be used to narrow the possibilities down to a single solution.

      So I settled on the following additional conditions to give a single solution:

      • The children are aged between 2 and 16, and their ages (expressed in years) are all different.
      • The husband and wife are currently aged less than 50.

      This Python program solves the revised puzzle. It runs in 159ms.

      Run: [ @repl.it ]

      from enigma import (subsets, irange, div, printf)
      
      # x is divisible by y
      divides = lambda x, y: div(x, y) is not None
      
      # consider sets of at least 3 children ([extra] with no repeated ages)
      for ages in subsets(irange(2, 16), min_size=3, select='C'):
        k = len(ages)
      
        # wife's current age is the sum
        w = sum(ages)
        # husbands age + 1 is w + k
        h = w + k - 1
      
        # [extra] husband and wife are less than 40
        if not (h < 50): continue
      
        # husbands current age is divisible by the age of only one child
        if not (sum(divides(h, x) for x in ages) == 1): continue
      
        # in 1 years time it is divisible by the ages of three children...
        if not (sum(divides(h + 1, x + 1) for x in ages) == 3): continue
        # ... and also the number of children ...
        if not divides(h + 1, k): continue
      
        # ... while the wifes age is divisible by only one child
        if not (sum(divides(w + 1, x + 1) for x in ages) == 1): continue
      
        # on one day the husbands age will divide the age of the eldest child
        # so their birthdays must be on consecutive days
        a = ages[-1]
        # so they don't divide in general either now or both incremented
        if divides(h, a) or divides(h + 1, a + 1): continue
        # but they do divide when one of them is incremented
        if not (divides(h + 1, a) or (divides(h, a + 1))): continue
      
        # output solution (w0 and h0 are ages at the birth of the first child)
        printf("k={k}, ages={ages}, w={w}, h={h} [{w0}, {h0}]", w0=w - a, h0=h - a)
      

      Solution: The children are aged: 3, 6, 7, 9, 10.

      The wife’s current age is 35 (the sum of the children’s ages). The husband’s current age is 39. (So they would be 25 and 29 at the birth of eldest child).

      Of the children’s current ages, only 3 divides into 39. But when the ages are all increased by one to 4, 7, 8, 10, 11 then 4, 8 and 10 divide into 40. And the wife will be 36, which is divisible by 4.

      During May the eldest child’s age (10) does not divide into the husband’s age (39), until the husband’s birthday, when he is 40. The next day is the eldest child’s birthday (11) and non-divisibility is resumed.

      The intended solution was apparently 1, 6, 7, 9, 12.

      Like

  • Unknown's avatar

    Jim Randell 11:01 am on 7 April 2019 Permalink | Reply
    Tags: , flawed   

    Brainteaser 1542: Precisely what do I mean? 

    From The Sunday Times, 29th March 1992 [link]

    There is a row of 10 boxes and each box contains one object, which is a knife, a fork or a spoon. Each of the three utensils is in at least one box. Here are five true statements to help you answer the questions below:

    1. A knife is in more boxes than a spoon is in;
    2. A spoon is in more boxes than a fork is in;
    3. A knife is not in precisely five boxes;
    4. A spoon is not in precisely three boxes;
    5. A fork is not in precisely half the number of boxes a spoon is in.

    How many boxes contain a knife?

    How many boxes contain a spoon?

    This puzzle is included in the book Brainteasers (2002), in which it appears in the following (slightly different) form:

    There is a row of ten boxes and each box contains one object, which is a knife, a fork or a spoon. There is at least one of each utensil. Here are five true statements to help you work out how many of each there are:

    • A knife is in more boxes than a spoon is in;
    • A spoon is in more boxes than a fork is in;
    • A knife is not in precisely five boxes;
    • A spoon is not in precisely three boxes;
    • A fork is not in precisely half the number of boxes a spoon is in.

    How many of each utensil are there?

    However I think both these formulations are flawed, in that under any reasonable interpretation there are no solutions. In the comments I present a variation that can be solved.

    [teaser1542]

     
    • Jim Randell's avatar

      Jim Randell 11:05 am on 7 April 2019 Permalink | Reply

      Having read the solution given in the book, I think the spirit of the puzzle can be maintained by phrasing it slightly differently:

      The National Museum of Cutlery in the small country of Ambiguity has an exhibit consisting of a row of ten boxes.

      Each box contains one object, which is either a knife, a fork or a spoon. There is at least one of each utensil.

      On a recent visit I heard five natives make the following true statements:

      1. A knife is in more boxes than a spoon is in.
      2. A spoon is in more boxes than a fork is in.
      3. A knife is not in precisely five boxes.
      4. A spoon is not in precisely three boxes.
      5. A fork is not in precisely half the number of boxes a spoon is in.

      How many of each utensil are there?

      And here is my solution:

      Suppose there are K knives, F forks and S spoons, each number has a value from 1 to 9.

      Looking at the statements:

      “A knife is in more boxes than a spoon is in”, seems to be an oddly worded way of saying: “there are more knives than spoons”:

      K > S

      Similarly: “A spoon is in more boxes than a fork is in”, seems to be saying:

      S > F

      We then have three statements of the form: “an X is not in precisely N boxes”

      I think there are two reasonable interpretations of this:

      (a) “The number of boxes containing an X, is not exactly N”

      i.e.:

      X ≠ N

      or:

      (b) “There are exactly N boxes, containing an object that is not an X”

      i.e.:

      10 − X = N

      The following Python 3 program considers these possible interpretations for the last three statements. It runs in 80ms.

      Run: [ @repl.it ]

      from enigma import (irange, join, printf)
      
      # decompose <t> into <k> increasing values
      def decompose(t, k, m=1, s=[]):
        if k == 1:
          if not (t < m):
            yield s + [t]
        else:
          for x in irange(m, t):
            yield from decompose(t - x, k - 1, x + 1, s + [x])
      
      # consider interpretations for:
      # "the number of boxes containing an <x> is <n>/<d>"
      def interpretations(x, n, d=1):
        # (a) "the number of boxes containing an <x> is exactly <n>/<d>"
        if d * x != n: yield 'a'
        # (b) "there are exactly <n>/<d> boxes containing an object that is not an <x>"
        if d * (10 - x) == n: yield 'b'
      
      # find possible values for F < S < K
      for (F, S, K) in decompose(10, 3):
        # consider possible interpretations for the last three statements
        ss = list(join(interpretations(*args)) for args in [(K, 5), (S, 3), (F, S, 2)])
        # each must have some interpretation
        if not all(ss): continue
        # output solution
        printf("F={F} S={S} K={K} {ss}")
      

      Solution: There is 1 fork, 4 spoons, 5 knives.

      The constraint (F < S < K) narrows the solution down to 4 possibilities:

      F=1, S=2, K=7
      F=1, S=3, K=6
      F=1, S=4, K=5
      F=2, S=3, K=5

      Only in the case (F=1, S=4, K=5) do the last three statements all have viable interpretations. These are:

      3. “A knife is not in precisely 5 boxes” = “There are exactly 5 boxes containing an object that is not a knife”
      4. “A spoon is not in precisely 3 boxes” = “The exact number of boxes containing a spoon is not 3”
      5. “A fork is not in precisely half the number of boxes a spoon is in” = “The exact number of boxes containing a fork is not half the exact number of boxes containing a spoon”

      or:

      3. “10 − K = 5”
      4. “S ≠ 3”
      5. “F ≠ S / 2”

      We can see each of these is a true statement, but they do not all use the same interpretation of the statement form. (Statement 3 uses the (b) interpretation. Statements 4, 5 use the (a) interpretation). This is why I changed the puzzle wording, so that the statements are made by different people. To have them made by the same person implies a consistent interpretation and gives no viable solutions.

      Like

  • Unknown's avatar

    Jim Randell 7:04 am on 19 March 2019 Permalink | Reply
    Tags: , flawed   

    Brain-Teaser 465: [Lifts] 

    From The Sunday Times, 26th April 1970 [link]

    Near my house is an impressive block of flats. It stands 16 storeys high, and each story is a lofty 15 feet from floor to floor. My old friends Bob and Horace operate the two lifts, and both start their shift each morning leaving the ground floor at 8 a.m. precisely.

    The two lifts make automatic compulsory stops at the ground level (there is no basement), the 12th and top floors. But below the 12th, Bob serves only the odd-numbered floors, and Horace the even numbers; these stops are also compulsory (up and down). All stops take just 10 seconds, except at ground level where both lifts wait for 20 seconds.

    Above the 12th both Bob and Horace stop as desired, going up and coming down. Both lifts travel between floors at identical speeds.

    Every morning the two attendants make a rendezvous to exchange newspapers and collect their coffee when their arrivals at a certain floor coincide exactly at two minutes after 11 a.m.

    In feet per second what the speed of each lift between stops?

    Note: In the UK the floors in buildings are: ground floor, first floor, second floor, etc.

    Also, as stated this puzzle does not appear to have a unique solution.

    An answer was published (with Teaser 467) stating:

    “This clever trap, with its nice reasoning, outweighed the slight mathematical bias and kept down the entry to a mixed handful.”

    But later, with Teaser 471 the following statement was made:

    “[465: Regretfully a wrong transposition led to a false calculation of time.]”

    In the comments I give a variation on the puzzle that does have a unique answer.

    This puzzle was originally published with no title.

    [teaser465]

     
    • Jim Randell's avatar

      Jim Randell 7:05 am on 19 March 2019 Permalink | Reply

      Replacing the third paragraph (“Above the 12th floor…”) with the following gives a puzzle that does have a unique solution, and it is the same as the published answer.

      The 13th floor is considered to be unlucky, so at the beginning of each day the attendants toss a coin to decide who should service it that day. The loser has to stop at the 13th floor each time they pass it, and the winner stops at the 14th floor each time they pass it. Both lifts take the same amount of time to travel between adjacent floors.

      This Python program can be used to investigate situations where the attendants follow a fixed schedule of stops. And it solves this variation puzzle in 412ms.

      Run: [ @repl.it ]

      from fractions import Fraction as F
      from enigma import printf
      
      # number of seconds between 08:00:00 and 11:02:00
      S = (3 * 60 + 2) * 60
      
      # wait at each floor (seconds)
      wait = [20] + [10] * 15
      
      # generate (<floor>, <seconds>, <n floors>)
      def stops(fs, wait=wait):
        s = n = f = 0
        while True:
          # going up
          for (i, x) in enumerate(fs):
            if i == 0: continue
            s += wait[f]
            n += (x - f)
            f = x
            yield (f, s, n)
          # going down
          for (i, x) in enumerate(reversed(fs)):
            if i == 0: continue
            s += wait[f]
            n += (f - x)
            f = x
            yield (f, s, n)
      
      # collect possible (f, s, n) tuples
      def collect(fs, xs):
        for (f, s, n) in stops(fs):
          if not (s < S): break
          if f in xs: yield (f, s, n)
      
      # solve for specific floors visited by B and H
      def solve(B, H):
        # find common floors
        xs = set(B).intersection(H)
        # collect (<floor>, <seconds>, <n floor>) tuples for each
        Bs = list(collect(B, xs))
        Hs = list(collect(H, xs))
      
        # consider possible meeting stops for B (at time S)
        for (fB, sB, nB) in Bs:
          # calculate time between floors
          t = F(S - sB, nB)
          # look for matching stops for H
          for (fH, sH, nH) in Hs:
            if fH == fB and sH + t * nH == S:
              printf("t={t}s [floor={fB}, B=(wait={sB}s, floors={nB}), H=(wait={sH}s, floors={nH})]")
      
      # send B to floor 13, H to floor 14
      solve(
        [0, 1, 3, 5, 7, 9, 11, 12, 13, 15], # floors for B
        [0, 2, 4, 6, 8, 10, 12, 14, 15], # floors for H
      )
      

      Solution: The time between floors is 3s, giving an average speed of 5 ft/s.

      By 11:02 am, Bob has spent 7410s waiting and travelled 1170 floors. Horace has has waited for 7140s and travelled 1260 floors.

      Like

  • Unknown's avatar

    Jim Randell 9:30 am on 9 March 2019 Permalink | Reply
    Tags: by: T Verschoyle, flawed   

    Brain-Teaser 462: [Crocodiles] 

    From The Sunday Times, 5th April 1970 [link]

    A friend of mine, who is headmistress of a small school, sends her fifteen girls for a walk every day in a crocodile of threes. She told me that she had for long been trying, unsuccessfully, to arrange that no two girls ever walked together in a trio more than once during a whole week; and she added that, denoting the girls by the first fifteen letters of the alphabet, she wanted A to walk with B and C on Sunday, and with the consecutive pairs of letters for the rest of the week, finishing with N and O on Saturday.

    “Well”, I replied, “if four more trios were specified, I could find a unique solution for your problem. But, if you want to work it out yourself, I shall help you by telling you B’s and C’s partners throughout the week:

    Mon: BHJ, CMN
    Tue: BIK, CLO
    Wed: BLN, CEF
    Thu: BMO, CDG
    Fri: BDF, CIJ
    Sat: BEG, CHK

    Furthermore, F, who is a bit of a snob as regards those lower in the alphabetical order, will be relieved to find that she does not have to walk with the two available furthest from herself in that order until Saturday.

    Now, you should be able to tell me with whom D walks on Sunday and on Wednesday.”

    This puzzle was originally published with no title.

    [teaser462]

     
    • Jim Randell's avatar

      Jim Randell 9:31 am on 9 March 2019 Permalink | Reply

      I’ve marked this puzzle as flawed for two reasons. Firstly when the solution was published it was acknowledged that there was not a unique answer, and secondly I’m not really sure that the constraint about F makes sense.

      My first thought was that it means that F partnered N and O (the two furthest along from F alphabetically) on Saturday, but N and O are already partnering A on Saturday. It does say the “two available furthest from herself”, so perhaps it means F partners L and M (the next furthest alphabetically), but L and M were partnering A on Friday, so can’t appear in a grouping on Saturday. In fact, according to the information we are given, the groups: ANO, BEG, CHK are already defined for Saturday, leaving DFIJLM, to be formed into viable groups. So maybe we are meant to partner F with J and M. This is the interpretation I ended up using, and it does generate the published answer(s). But I think there is still a problem (see below).

      This Python 3 program solves the puzzle recursively in 865ms.

      Run: [ @repl.it ]

      from itertools import combinations
      from enigma import unpack, partitions, join, update, flatten, printf
      
      # check no pairs are repeated
      def pairs(ps, ts):
        ps = ps.copy()
        for t in ts:
          for p in combinations(t, 2):
            if p in ps: return None
            ps.add(p)
        return ps
      
      # complete the groups, with pairs ps already used
      def solve(groups, ps):
        # find days with missing groups
        gs = list((k, vs) for (k, vs) in groups.items() if len(vs) < 5)
        if not gs:
          yield groups
        else:
          # choose the day with the fewest missing groups
          (k, vs) = min(gs, key=unpack(lambda k, vs: 5 - len(vs)))
          # form the remaining kids into groups
          for ts in partitions(kids.difference(*vs), 3):
            ts = list(join(sorted(t)) for t in ts)
            ps2 = pairs(ps, ts)
            if ps2:
              yield from solve(update(groups, [(k, sorted(vs + ts))]), ps2)
      
      # the kids
      kids = set("ABCDEFGHIJKLMNO")
      
      # the groupings we are given
      groups = dict(
        Sun=["ABC"],
        Mon=["ADE", "BHJ", "CMN"],
        Tue=["AFG", "BIK", "CLO"],
        Wed=["AHI", "BLN", "CEF"],
        Thu=["AJK", "BMO", "CDG"],
        Fri=["ALM", "BDF", "CIJ"],
        Sat=["ANO", "BEG", "CHK", "FJM"],
      )
      
      # check no pairing is duplicated among the given groups
      ps = pairs(set(), flatten(groups.values()))
      assert ps
      
      # solve for the remaining groups
      for gs in solve(groups, ps):
        # find the group on day d for child x
        get = lambda d, x: list(t for t in gs[d] if x in t)[0]
        # a measure for F's partners
        fn = lambda d: sum(int(x, 25) - 9 for x in get(d, 'F') if x != 'F')
        # output the groups
        for (k, vs) in gs.items():
          printf("{k}: {vs} [{m}]", vs=join(vs, sep=" "), m=fn(k))
        # D's groups on Sun and Wed
        printf("[D] Sun={S} Wed={W}", S=get("Sun", 'D'), W=get("Wed", 'D'))
        printf()
      

      Solution: There are two possible solutions: (1) D partners H and O on Sunday, and K and M on Wednesday; (2) D partners K and N on Sunday, and J and O on Wednesday.

      The full groupings look like this:

      Sun: ABC DHO EJL FKN GIM
      Mon: ADE BHJ CMN FIO GKL
      Tue: AFG BIK CLO DJN EHM
      Wed: AHI BLN CEF DKM GJO
      Thu: AJK BMO CDG EIN FHL
      Fri: ALM BDF CIJ EKO GHN
      Sat: ANO BEG CHK DIL FJM

      Sun: ABC DKN EIM FHO GJL
      Mon: ADE BHJ CMN FKL GIO
      Tue: AFG BIK CLO DHM EJN
      Wed: AHI BLN CEF DJO GKM
      Thu: AJK BMO CDG EHL FIN
      Fri: ALM BDF CIJ EKO GHN
      Sat: ANO BEG CHK DIL FJM

      And now we run into the problem with F, their “worst” day is suppose to be Saturday, when they partner J and M.

      But in the first case, F partners K and N on Sunday, each of these is one step further along the alphabet than Saturday’s partners, so is surely a less desirable situation. If we just sum the positions in the alphabet of her partners to get a measure of “badness”, the partnering I and O on Monday is also less desirable than Saturday.

      Using the same measure we find that in the second case, Sunday, Monday and Thursday all score as badly as Saturday for F.

      And if we use other measures (e.g. looking for the “best” of the two partners, or the “worst”) we find that in neither of these scenarios does Saturday does provide F with their worst partnering of the week.

      Further, if we consider all possible pairings for F on Saturday (and not a specific one) we find it is not possible to solve the puzzle so F has her worst day on Saturday.

      So maybe it would have just been better to say: “F doesn’t get on with her sisters, J and M. So she will be relieved to find she does not have to walk with them until Saturday”. Or just come straight out with it: “F walked with J and M on Saturday”. But that still leaves the problem of the two answers. Although an extra condition disallowing one of the groupings in one of the answers would sort that out.

      Like

  • Unknown's avatar

    Jim Randell 8:06 am on 8 March 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 2938: Numerophobia 

    From The Sunday Times, 13th January 2019 [link] [link]

    In Letterland there are no numerals. They use the decimal system of counting just like we do but the digits 0-9 are represented by the first ten letters of the alphabet AJ inclusive but in no particular order. The following calculations are typical:

    A + G = C
    B × J = FH
    GE × AI = HDB

    What number is represented by ABCDEFGHIJ?

    As stated this puzzle does not have a unique solution.

    This puzzle was not included in the book The Sunday Times Teasers Book 1 (2021).

    [teaser2938]

     
    • Jim Randell's avatar

      Jim Randell 8:07 am on 8 March 2019 Permalink | Reply

      We can feed the alphametic expressions directly to the [[ SubstitutedExpression() ]] solver from the enigma.py library.

      This run-file executes in 125ms.

      Run: [ @replit ]

      #! python3 -m enigma -rr
      
      SubstitutedExpression
      
      --answer="ABCDEFGHIJ"
      
      "A + G = C"
      "B * J = FH"
      "GE * AI = HDB"
      

      Solution: There are two solutions: ABCDEFGHIJ = 1840253697, and ABCDEFGHIJ = 3840951627.

      The two solutions arise as we can swap the values of (A, E) with (G, I). One of them is (1, 2) and the other is (3, 9).

      Apparently the setter was unaware that there were two solutions, which seems a bit odd as this kind of puzzle can very easily be checked. For example my own alphametic solver is available here [ https://repl.it/@jim_r/alphametic ]. Click “Run”, enter the expressions, and you get the two solutions straight away. [Note: As of 2024 code sharing via replit no longer works].

      Here’s an example transcript:

      Python 3.6.1 (default, Dec 2015, 13:05:11)
      [GCC 4.8.2] on linux
      expr[0] (or enter) >>> A + G = C
      expr[1] (or enter) >>> B * J = FH
      expr[2] (or enter) >>> GE * AI = HDB
      expr[3] (or enter) >>>
      (A + G = C) (B * J = FH) (GE * AI = HDB)
      (1 + 3 = 4) (8 * 7 = 56) (32 * 19 = 608) / A=1 B=8 C=4 D=0 E=2 F=5 G=3 H=6 I=9 J=7
      (3 + 1 = 4) (8 * 7 = 56) (19 * 32 = 608) / A=3 B=8 C=4 D=0 E=9 F=5 G=1 H=6 I=2 J=7
      [2 solutions]
      [timing] elapsed time: 0.0016964s (1.70ms)
      

      The published solution is:

      Teaser 2938
      There were two possible correct answers: 1840253697 or 3840951627.
      We apologise for any confusion.

      Like

    • GeoffR's avatar

      GeoffR 1:20 pm on 8 March 2019 Permalink | Reply

      % A solution in MinZinc 
      include "globals.mzn";
      
      var 0..9: A; var 0..9: B; var 0..9: C; var 0..9: D; var 0..9: E;
      var 0..9: F; var 0..9: G; var 0..9: H; var 0..9: I; var 0..9: J;
      
      constraint A != 0 /\ G != 0 /\ C != 0 /\ B != 0 
      /\ J != 0 /\ F != 0 /\ H != 0;
      
      constraint all_different ( [A,B,C,D,E,F,G,H,I,J] );
      
      var 10..99: FH = 10*F + H;
      var 10..99: GE = 10*G + E;
      var 10..99: AI = 10*A + I;
      var 100..999: HDB = 100*H + 10*D + B;
      
      constraint A + G == C;
      constraint B * J == FH;
      constraint GE * AI = HDB;
      
      solve satisfy;
      
      output [ "ABCDEFGHIJ = " ++ show(A),show(B),show(C),show(D),show(E),
      show(F),show(G),show(H),show(I),show(J) ];
      
      % ABCDEFGHIJ = 3840951627
      % ABCDEFGHIJ = 1840253697
      
      

      Like

  • Unknown's avatar

    Jim Randell 9:32 am on 4 March 2019 Permalink | Reply
    Tags: by: Arithmedicus, flawed   

    Brain-Teaser 459: [Grandchildren] 

    From The Sunday Times, 8th March 1970 [link]

    Grandpa was as pleased as Punch when he heard that his large flock of grandchildren would be there at his birthday party, but he couldn’t remember how many there were. So he wrote to his youngest daughter, who knew he liked problems, and got back the answer:

    “There are just enough children to arrange them in pairs in such a way that the square of the age of the first of a pair added to thrice the square of the age of the second give the same total for every pair. The eldest is still a teenager. You remember that I have twins one year old.”

    How many grandchildren are there?

    This puzzle was originally published with no title.

    [teaser459]

     
    • Jim Randell's avatar

      Jim Randell 9:33 am on 4 March 2019 Permalink | Reply

      I think the wording of this puzzle could be improved. Saying there are “just enough” children sounds like we are looking for the minimum number of children to satisfy the conditions, given that there are two ages of 1 amongst the children, and one teenager. So we already have three values that must be used in the pairs. The smallest potential set would be two pairs, and this is achievable, giving an answer of 4 children.

      But it appears this is not the solution the setter had in mind. Instead it seems we want the largest possible number of children that can be formed into different pairs that give the same value for the function. If we were to allow duplicate pairs (i.e. pairs of children with the same ages in the same order), then we could increase the number of children to be as large as we want.

      Instead this program looks to group the ages of pairs of children into sets that give the same value for the function. We then need a set that has two 1’s and also value between 13 and 19. Then we look for the maximum number of different pairs of children possible, and this is the answer that was published.

      This Python program runs in 81ms.

      Run: [ @repl.it ]

      from enigma import (defaultdict, irange, subsets, printf)
      
      ages = set(irange(1, 19))
      
      # record the pairs by total
      d = defaultdict(list)
      
      # consider pairs of ages
      for (a, b) in subsets(ages, size=2, select='M'):
        n = a**2 + 3 * b**2
        d[n].append((a, b))
      
      # consider the values found
      for k in sorted(d.keys()):
        ps = d[k]
        # look for pairs where 1 occurs twice
        if not (sum(p.count(1) for p in ps) == 2): continue
        # and the eldest is a teenager
        if not (max(max(p) for p in ps) > 12): continue
        # output solution
        printf("{k} -> {ps}")
      

      Solution: There are 12 grandchildren.

      It turns out there is only one possible total that gives a viable set of pairs. The pairs are:

      (1, 11) (8, 10) (11, 9) (16, 6) (17, 5) (19, 1)

      Each giving the value of 364 when the function f(a, b) = a^2 + 3b^2 is applied to them.

      So there two 1 year olds (the twins) and also two 11 year olds.

      If we had four children of ages 1, 1, 11, 19, we would have “just enough” to form them into 2 pairs – (1, 11) and (19, 1) – that give the same value under the function, and there are two 1’s and a teenager involved. So this would be the answer if we take a strict interpretation of the wording.

      Similarly, if we allow duplication among the pairs we could have 14 children, or 16, etc.

      Like

      • Jim Randell's avatar

        Jim Randell 10:07 am on 4 March 2019 Permalink | Reply

        A variation would be to look for the largest number of children of different ages (apart from the twins) that can form the pairs.

        In this case we would have to discard the (11, 9) pair to leave:

        (1, 11) (8, 10) (16, 6) (17, 5) (19, 1)

        So there would be 10 children.

        Like

  • Unknown's avatar

    Jim Randell 7:12 am on 3 March 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 2940: Getting there in the end 

    From The Sunday Times, 27th January 2019 [link]

    A tractor is ploughing a furrow in a straight line. It starts from rest and accelerates at a constant rate, taking a two-digit number of minutes to reach its maximum speed of a two-digit number of metres per minute. It has, so far, covered a three-digit number of metres. It now maintains that maximum speed for a further single-digit number of minutes and covers a further two-digit number of metres. It then decelerates to rest at the same rate as the acceleration. I have thus far mentioned ten digits and all of them are different.

    What is the total distance covered?

    As stated this puzzle does not have a unique solution.

    This puzzle was not included in the book The Sunday Times Teasers Book 1 (2021).

    [teaser2940]

     
    • Jim Randell's avatar

      Jim Randell 7:12 am on 3 March 2019 Permalink | Reply

      The tractor starts at rest:

      u = 0

      It then accelerates, at constant rate a, in time t1, to velocity v:

      v = a.t1
      a = v/t1

      During this period it has covered a distance d1:

      d1 = (1/2)a(t1^2) = v.t1/2

      It continues at a constant velocity v, for time t2, and covers distance d2:

      d2 = v.t2

      It then decelerates to rest, at a rate of −a, covering distance d1 again.

      The required answer being:

      d1 + d2 + d1 = v(t1 + t2)

      We can consider the alphametic expressions where:

      t1 = AB; v = CD; d1 = EFG; t2 = H; d2 = IJ

      This can be easily solved by the [[ SubstitutedExpression() ]] solver from the enigma.py library.

      This run-file executes in 126ms.

      Run: [ @repl.it ]

      #! python3 -m enigma -rr
      
      SubstitutedExpression
      
      --answer="2 * EFG + IJ"
      
      "div(AB * CD, 2) = EFG"
      "CD * H = IJ"
      

      Solution: There are three possible total distances: 646m, 864m, 1316m.

      None of the solutions are particularly realistic. Each of them involve the tractor accelerating incredibly slowly for a very long time to reach an extremely modest top speed, and later take just as long to decelerate. Perhaps with a change of units the problem could made to apply to something that does take a long time to decelerate, like a train, oil tanker or spaceship.

      It would also have been easy to require just one of the possible answers, maybe by specifying the answer has 4 digits (1316m), or that all the digits are different (864m).


      The published solution is:

      Teaser 2940
      There were three possible correct answers.
      646, 864 or 1316m. We apologise for any confusion.

      Like

  • Unknown's avatar

    Jim Randell 10:07 am on 26 February 2019 Permalink | Reply
    Tags: , flawed   

    Brain-Teaser 455: [Darts teams] 

    From The Sunday Times, 1st February 1970 [link]

    Every week we field a village darts team of 3 men, one from each of our pubs (Plough, Queen’s Head, and Roebuck). Altogether we can call on 14 players (whose names, luckily, start respectively with the first 14 letters of the alphabet): five of them frequent the Plough, six the Queen’s Head and seven the Roebuck, the apparent discrepancy is explained by the thirsts of Ernie, Fred, Len and Mark, all of whom are “two-pub men” and are thus eligible to represent either of their haunts.

    For over three years we have picked a different team each week and have just exhausted all 162 possible combinations. The last two teams were:

    Joe, Nigel, Charlie
    Charlie, Fred, Harry

    For the next seven weeks we are waiving the one-man-per-pub rule and have picked teams which have not so far played together. The are:

    Ernie, Len, Mark
    Ian, Fred, Alan
    Joe, Fred, George
    Len, Mark, Keith
    Fred, Keith, Nigel
    Ernie, Len, Nigel
    Ian, Joe, and one other to be picked from a hat on the night.

    Which darts players frequent the Roebuck?

    This puzzle was originally published with no title.

    [teaser455]

     
    • Jim Randell's avatar

      Jim Randell 10:07 am on 26 February 2019 Permalink | Reply

      I found two solutions for this puzzle, although with a slight change in the wording we could arrive at a unique solution.

      This Python program runs in 226ms.

      Run: [ @repl.it ]

      from itertools import product, permutations, combinations
      from enigma import icount, unpack, printf
      
      # all the players
      players = "ABCDEFGHIJKLMN"
      
      # players with dual allegiance
      duals = "EFLM"
      
      # the pubs
      pubs = set("PQR")
      
      # do the three sets form a team
      def team(a, b, c):
        for (x, y, z) in permutations(pubs):
          if x in a and y in b and z in c: return True
        return False
      
      # choose the "missing" pub for the duals
      for s1 in product(pubs, repeat=4):
        (E, F, L, M) = (pubs.difference([x]) for x in s1)
      
        # ELM do not form a team
        if team(E, L, M): continue
      
        # choose (single) pubs for K, N
        for s2 in product(pubs, repeat=2):
          (K, N) = (set([x]) for x in s2)
      
          # KLM, FKN, ELN do not form teams
          if team(K, L, M) or team(F, K, N) or team(E, L, N): continue
      
          # CJN do form a team
          for s3 in permutations(pubs.difference(N)):
            (C, J) = (set([x]) for x in s3)
      
            # remaining assignments for given combinations, AGHI
            for s4 in product(pubs, repeat=4):
              (A, G, H, I) = (set([x]) for x in s4)
      
              # check the remaining combinations
              if not (team(C, F, H)) or team(A, F, I) or team(F, G, J): continue
      
              # which leaves B and D
              for s5 in product(pubs, repeat=2):
                (B, D) = (set([x]) for x in s5)
      
                table = (A, B, C, D, E, F, G, H, I, J, K, L, M, N)
      
                # P, Q, R should have teams of 5, 6, 7
                (P, Q, R) = (icount(table, (lambda x: p in x)) for p in 'PQR')
                if (P, Q, R) != (5, 6, 7): continue
      
                # count the total possible teams
                t = icount(combinations(table, 3), unpack(team))
                # there should be 162
                if t != 162: continue
      
                # find how many unused IJ? combinations there are
                ijs = list(p for (p, x) in zip(players, table) if p not in 'IJ' and not team(I, J, x))
                # there should be at least 2
                if len(ijs) < 2: continue
      
                # who plays for R
                Rs = list(p for (p, x) in zip(players, table) if 'R' in x)
      
                printf("Rs = {Rs}")
                printf("  A={A} B={B} C={C} D={D} E={E} F={F} G={G} H={H} I={I} J={J} K={K} L={L} M={M} N={N}")
                printf("  ijs={ijs}")
                printf()
      

      Solution: A, B, D, F, G, I, J are on the Roebuck team.

      This solution assumes that the final team member of the I+J+? team that is picked out of the hat can be any of the other players (i.e. I and J have never played together on a team before).

      The team allegiances in this case are:

      P = C, E, F, L, M [5]
      Q = E, H, K, L, M, N [6]
      R = A, B, D, F, G, I, J [7]

      However, I took the construction of final I+J+? team by picking a name out of a hat to require only that there should be more than one candidate to placed in the hat. If we have the following team allegiances:

      P = E, F, J, L, M [5]
      Q = E, H, K, L, M, N [6]
      R = A, B, C, D, F, G, I [7]

      Then this is also a solution to the puzzle. In this case the remaining possible partners for I+J+? are: A, B, C, D, F, G.

      Like

  • Unknown's avatar

    Jim Randell 10:33 am on 12 February 2019 Permalink | Reply
    Tags: , flawed   

    Teaser 2503: [Cube reflections] 

    From The Sunday Times, 12th September 2010

    → See: [ Teaser 2503 at Enigmatic Code ]

    This puzzle was originally published with no title.

    [teaser2503]

     
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