Tagged: by: Nick MacKinnon Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 11:19 am on 10 November 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 1942: Eurosceptics 

    From The Sunday Times, 5th December 1999 [link]

    Ruritania is reluctant to adopt the euro as it has a sensible currency of its own. The mint issues the coins in four denominations, the value of each being proportional to its radius. The total value of the four, in euros, is 28.

    The four coins are available in a clever presentation pack. It consists of a triangular box of sides 13 cm, 14 cm and 15 cm. The largest coin just fits into the box, touching each of its sides, roughly as shown:

    Then there are three straight pieces of thin card inside the box. Each touches the large coin and is parallel to a side of the box. This creates three smaller triangles in the corners of the box. The three remaining coins just fit into the box, with one in each of these small triangles. Each coin touches all three sides of the triangle.

    Unfortunately I have lost the smallest coin from my presentation pack.

    What, in euros, is its value?

    This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.

    [teaser1942]

     
    • Jim Randell's avatar

      Jim Randell 11:20 am on 10 November 2020 Permalink | Reply

      See: [ @Wikipedia ] for more details on incircles and excircles.

      Suppose a, b, c, d are the radii of the four coins (from largest to smallest).

      The inradius of a triangle can be calculated as the area of the triangle divided by the semi-perimeter.

      So for the large triangle we have:

      a = A / S

      where:

      S = semi-perimeter = (13 + 14 + 15) / 2 = 21
      A = area = sqrt(21.8.7.6) = 84

      So:

      a = 84/21 = 4

      Then considering the triangle containing the next smallest coin (radius = b), this is a version of the large triangle scaled down by a factor of (say) q.

      So it has a semi-perimeter of 21q, and an area of 84q² so:

      b = 84q² / 21q = 4q
      q = b / 4

      But the largest coin is an excircle of this smaller triangle and so its radius is given by:

      a = b.21q / (21q − 13q)
      a = 21b / (21 − 13) = b(21/8)
      b = (8/21)a = 32/21

      Similarly, for coins in the other corners:

      c = (7/21)a = 4/3
      d = (6/21)a = 8/7

      Now, if the radii are multiplied by factor f to get the value in euros we have:

      (4 + 32/21 + 4/3 + 8/7)f = 28
      8f = 28
      f = 7/2

      So the coins are worth:

      f.a = 14 euros
      f.b = 5 + 1/3 euros
      f.c = 4 + 2/3 euros
      f.d = 4 euros

      Which do indeed give a total of 28 euros.

      So, we have worked out the radii and value of each of the four coins.

      Solution: The smallest coin is worth 4 euros.

      The four coins are:

      radius = 40.0 mm; value = 14.00 euro
      radius = 15.2 mm; value = 5.33 euro
      radius = 13.3 mm; value = 4.67 euro
      radius = 11.4 mm; value = 4.00 euro

      Here’s a program that performs the same calculations:

      Run: [ @repl.it ]

      from enigma import fdiv, sqrt, multiply, printf
      
      # total value of the coins
      T = 28
      
      # the sides of the large triangle
      sides = (13, 14, 15)
      
      # calculate the radius of the largest coin
      S = fdiv(sum(sides), 2)
      A = sqrt(S * multiply(S - x for x in sides))
      a = fdiv(A, S)
      
      # and the three coins in the corners
      (b, c, d) = (fdiv(a * (S - x), S) for x in sides)
      
      # multiplier f: radius -> value
      f = fdiv(T, a + b + c + d)
      
      # output the values of the coins
      printf("[S={S} A={A} f={f}]")
      for (r, n) in zip((a, b, c, d), "abcd"):
        printf("{n}: {r:.1f} mm -> {v:.2f} euro", r= r * 10, v=r * f)
      

      Like

  • Unknown's avatar

    Jim Randell 10:27 am on 8 November 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 1935: Turner painting 

    From The Sunday Times, 17th October 1999 [link]

    “Yet more storms” is a gigantic painting in the State Gallery. It is currently on the wall of the 27-foot-wide “Modern masters” corridor, but the curator feels that it would look better on the 64-foot-wide “Britain’s impressionists” corridor, which meets the “Modern masters” one at right angles.

    So he instructs his staff to slide the painting around the corner without tilting it. His staff manage to turn the painting as requested, but had it been any wider it would not have fitted around the corner.

    How wide is the painting?

    This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.

    [teaser1935]

     
    • Jim Randell's avatar

      Jim Randell 10:27 am on 8 November 2020 Permalink | Reply

      We examined the general case of this problem in Enigma 34.

      And maximum width of the painting is given by:

      z = (a^(2/3) + b^(2/3))^(3/2)

      z = \left( a^{2/3} + b^{2/3} \right)^{3/2}

      In particular this means that if we have a Pythagorean triple (x, y, z) (so: x² + y² = z²), then the maximum width painting for corridors of width x³ and y³ is z³.

      In this case: a = 27 = 3³ and b = 64 = 4³, so z = 5³ = 125.

      Solution: The painting is 125 ft wide.

      Like

      • Jim Randell's avatar

        Jim Randell 10:20 pm on 11 November 2020 Permalink | Reply

        Or a numerical solution:

        from math import (cos, sin, pi)
        from enigma import (fdiv, find_min, printf)
        
        # width of the legs
        (a, b) = (27, 64)
        
        # length of rod
        z = lambda theta: fdiv(a, cos(theta)) + fdiv(b, sin(theta))
        
        # find the minimum length
        r = find_min(z, 0, 0.5 * pi)
        
        # output solution
        printf("width = {r.fv:g} ft")
        

        Like

    • Frits's avatar

      Frits 4:13 pm on 10 November 2020 Permalink | Reply

      #    -----+-----------+
      #     27  .\          |
      #    -----+---\  W    |
      #           x |  \    |
      #             |y    \ |
      #             |.......+
      #             |       |
      #             |  64   |
      #
      # W =  Width painting
      #
      # W^2 = (x + 64)^2 + (y + 27)^2
      #
      # x / 27 = 64 / y --> xy = 27*64 --> y = 27*64/x
      #
      # W = ((x + 64)^2 + (27*64/x + 72)^2)^0.5
      #
      # W is minimal if W' = 0
      #
      # W' = 0.5(((x + 64)^2 + (27*64/x + 72)^2)^-0.5 * 
      #      (2 * (x + 64) + 2 * (27*64/x + 27)) * 
      #      -27*64/x^2  
      #
      # term 2, 3 = x + 64 + (27*64/x + 27)) * -27*64/x^2 
      #           = x + 64 - 27*27*64/x^2 - (27*64)^2/x^3
      #           = x^4 + 64 * x^3 - 27*27*64 * x - (27*64)^2
      #           = x^3 * (x + 64) - 27*27*64 * (x + 64)
      #           = (x^3 - 27*27*64) * (x + 64)
      #
      # W' = 0 if x = -64 or x = 36, disregard negative x
      #
      # x = 36 --> y = 48
      #
      # W^2 = (36 + 64)^2 + (48 + 27)^2 = 15625 --> W = 125
      

      Like

    • Frits's avatar

      Frits 7:58 pm on 10 November 2020 Permalink | Reply

      from enigma import SubstitutedExpression
      
      # the alphametic puzzle
      p = SubstitutedExpression(
        [
         # find the length of the shortest line segment from (UVW, 0) to (0, XYZ)
         # that passes through (27, 64).
         #
         # 64 / (UVW - 27) = (XYZ - 64) / 27
         
         "UVW*XYZ - 64*UVW == 27*XYZ",
         "UVW > 0",
         "XYX > 0",
        ],
        answer="((UVW)**2 + (XYZ)**2)**0.5, UVW, XYZ",
        d2i={},
        distinct="",
        accumulate=min,
        verbose=0)   
          
      # solve the puzzle
      r = p.run()
      
      ans = list(r.accumulate)
      print("answer =",ans[0])
      
      # answer =  125.0
      

      Like

  • Unknown's avatar

    Jim Randell 8:31 am on 1 September 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 1885: Sacred sign 

    From The Sunday Times, 1st November 1998 [link]

    The “Sacred Sign of Solomon” consists of a pentagon whose vertices lie on a circle, roughly as shown:

    Starting at one of the angles and going round the circle the number of degrees in the five angles of the large pentagon form an arithmetic progression; i.e., the increase from the first to the second equals the increase from the second to the third, etc.

    As you can see, the diagonals form a small inner pentagon and in the case of the sacred sign one of its angles is a right angle.

    What are the five angles of the larger pentagon?

    This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.

    [teaser1885]

     
    • Jim Randell's avatar

      Jim Randell 8:32 am on 1 September 2020 Permalink | Reply

      If the five sides of the pentagon are A, B, C, D, E, then the angles subtended by each side at the circumference of the circle are all equal, say, a, b, c, d, e.

      (The angles in the small pentagon, such as ace denote the sum of the three symbols, i.e. (a + c + e) etc).

      We see that: a + b + c + d + e = 180° (from many triangles, cyclic quadrilaterals, and the angles subtended at the centre of the circle).

      The internal angles of the pentagon are an arithmetic progression, say: (x − 2y, x − y, x, x + y, x + 2y).

      So, let’s say:

      a + b + e = x − 2y
      a + b + c = x − y
      b + c + d = x
      c + d + e = x + y
      a + d + e = x + 2y

      And these angles sum to 540°.

      5x = 540°
      x = 108°

      And if: x = b + c + d = 108°, then: a + e = 72°

      So starting with: a + d + e = x + 2y, we get:

      72° + d = 108° + 2y
      d = 36° + 2y

      Similarly we express each of the angles a, b, c, d, e in terms of y:

      a = 36° + y
      b = 36° − 2y
      c = 36°
      d = 36° + 2y
      e = 36° − y

      The internal angles of the small pentagon are:

      a + c + e = 108°
      a + b + d = 108° + y
      b + c + e = 108° − 3y
      a + c + d = 108° + 3y
      b + d + e = 108° − y

      And one of these is 90°.

      Our candidates are (b + c + e) and (b + d + e).

      b + c + e = 90° ⇒ y = 6°
      a = 42°
      b = 24°
      c = 36°
      d = 48°
      e = 30°

      And the angles of the large pentagon are then:

      a + b + e = 96°
      a + b + c = 102°
      b + c + d = 108°
      c + d + e = 114°
      a + d + e = 120°

      For the other candidate:

      b + d + e = 90° ⇒ y = 18°
      a = 54°
      b = 0°
      c = 36°
      d = 72°
      e = 18°

      This is not a viable solution, so:

      Solution: The angles of the larger pentagon are: 96°, 102°, 108°, 114°, 120°.

      Like

      • Jim Randell's avatar

        Jim Randell 11:54 am on 1 September 2020 Permalink | Reply

        Here’s a drawing of the symbol, with the two perpendicular lines indicated:

        Like

  • Unknown's avatar

    Jim Randell 8:37 am on 18 August 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Brainteaser 1847: Home’s best 

    From The Sunday Times, 8th February 1998 [link]

    Four football teams — Albion, Borough, City and District — each play each other twice, once at home and once away. They get three points for a win and one for a draw. Last season, each team did worse in the away match than in the corresponding home match, scoring fewer goals and getting fewer points. The final position was as follows:

    What were the two scores when Borough played District?

    This is the final puzzle to use the title Brainteaser. The following puzzle is Teaser 1848.

    [teaser1847]

     
    • Jim Randell's avatar

      Jim Randell 8:39 am on 18 August 2020 Permalink | Reply

      This Python program uses the [[ Football() ]] helper class from the enigma.py library.

      It runs in 452ms.

      Run: [ @repl.it ]

      from enigma import Football, printf
      
      # scoring system
      football = Football(games="wdl", points=dict(w=3, d=1))
      
      # check home matches have more points and more goals than away matches
      def check(Hs, As):
        for (H, A) in zip(Hs, As):
          if not(H[0] > A[1]): return False
          (h, a) = football.outcomes([H, A], [0, 1])
          if not(football.points(h) > football.points(a)): return False
        return True
      
      # choose C's six games (home, away)
      for (CA, CB, CD, AC, BC, DC) in football.games(repeat=6):
        # table for C
        tC = football.table([CA, CB, CD, AC, BC, DC], [0, 0, 0, 1, 1, 1])
        if not(tC.points == 7): continue
      
        # remaining matches for D
        for (DA, DB, AD, BD) in football.games(repeat=4):
          # table for D
          tD = football.table([DA, DB, DC, AD, BD, CD], [0, 0, 0, 1, 1, 1])
          if not(tD.points == 5): continue
      
          # remaining matches (for A and B)
          for (AB, BA) in football.games(repeat=2):
            # table for A, B
            tA = football.table([AB, AC, AD, BA, CA, DA], [0, 0, 0, 1, 1, 1])
            tB = football.table([BA, BC, BD, AB, CB, DB], [0, 0, 0, 1, 1, 1])
            if not(tA.points == 12 and tB.points == 8): continue
      
            # make possible scores (for C)
            for (sCA, sCB, sCD, sAC, sBC, sDC) in football.scores([CA, CB, CD, AC, BC, DC], [0, 0, 0, 1, 1, 1], 3, 5):
              # check the home matches were better than the away matches
              if not check([sCA, sCB, sCD], [sAC, sBC, sDC]): continue
      
              # remaining scores (for D)
              for (sDA, sDB, sAD, sBD) in football.scores([DA, DB, AD, BD], [0, 0, 1, 1], 9, 13, [sCD, sDC], [1, 0]):
                # check home matches were better than away matches
                if not check([sDA, sDB, sDC], [sAD, sBD, sCD]): continue
      
                # remaining scores (for A)
                for (sAB, sBA) in football.scores([AB, BA], [0, 1], 15, 8, [sAC, sAD, sCA, sDA], [0, 0, 1, 1]):
                  # check for/against B
                  (fB, aB) = football.goals([sBA, sBC, sBD, sAB, sCB, sDB], [0, 0, 0, 1, 1, 1])
                  if not(fB == 12 and aB == 13): continue
                  # check home matches were better than away matches
                  if not check([sAB, sAC, sAD], [sBA, sCA, sDA]): continue
                  if not check([sBA, sBC, sBD], [sAB, sCB, sDB]): continue
      
                  printf("AB={AB}:{sAB} AC={AC}:{sAC} AD={AD}:{sAD} / BA={BA}:{sBA} CA={CA}:{sCA} DA={DA}:{sDA}")
                  printf("BA={BA}:{sBA} BC={BC}:{sBC} BD={BD}:{sBD} / AB={AB}:{sAB} CB={CB}:{sCB} DB={DB}:{sDB}")
                  printf("CA={CA}:{sCA} CB={CB}:{sCB} CD={CD}:{sCD} / AC={AC}:{sAC} BC={BC}:{sBC} DC={DC}:{sDC}")
                  printf("DA={DA}:{sDA} DB={DB}:{sDB} DC={DC}:{sDC} / AD={AD}:{sAD} BD={BD}:{sBD} CD={CD}:{sCD}")
                  printf()
      

      Solution: The scores in the Borough vs. District matches were: B (home) vs. D (away) = 4 – 2; D (home) vs. B (away) = 3 – 3.

      The scores in the matches are: (home vs. away)

      A vs B = 4 – 1; A vs C = 2 – 0; A vs D = 3 – 1
      B vs A = 3 – 3; B vs C = 1 – 0; B vs D = 4 – 2
      C vs A = 1 – 1; C vs B = 1 – 0; C vs D = 1 – 0
      D vs A = 2 – 2; D vs B = 3 – 3; D vs C = 1 – 0

      Like

  • Unknown's avatar

    Jim Randell 7:12 am on 18 June 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Brainteaser 1819: Early bath 

    From The Sunday Times, 27th July 1997 [link]

    There are 20 teams in one country’s premier league. They each play each other once in the first half of the season, and then they each play each other a second time in the rest of the season. Each team plays each Saturday of the season, earning three points for a win and one point for a draw. At the end of the season the bottom three teams are relegated and the top team wins the league championship.

    Last season was the most boring ever. It was possible to determine the relegated teams well before the end of the season. In fact it would be impossible in any season to be able to determine the three relegated teams in fewer weeks.

    Three further Saturdays after the relegations were determined the league championship was also determined when the league leaders were in a 0-0 draw and then found that they were unassailable. There were great celebrations that night.

    At that time, how many points did the current top two teams have?

    This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.

    [teaser1819]

     
    • Jim Randell's avatar

      Jim Randell 7:12 am on 18 June 2020 Permalink | Reply

      After a tortuous chain of reasoning we arrive at the answer:

      In the first half of the season there are C(20, 2) = 190 matches, and then another 190 in the second half of the season. Each team plays 19 matches in the first half of the season, and another 19 matches in the second half of the season. The season lasts 38 weeks, with 10 matches played each week.

      At some point there are 3 teams doomed to relegation, as they cannot possibly catch up with any of the remaining 17 teams.

      Suppose in the first half of the tournament there are three teams that lose all their matches, except the matches they play amongst themselves, which are drawn.

      Each of the three doomed teams has only 2 points (from their draws with the other two doomed teams). If all the other 187 matches were won outright there are 187×3 = 561 points to distribute between the remaining 17 teams. This gives an average of 33 points per team. But, if one of the doomed teams were to win all their matches in the second half of the tournament they would end up with 2 + 3×19 = 59 points, so their relegation is not guaranteed by the end of the first half of the tournament.

      If we carry on for k weeks into the second half of the tournament, with each doomed team losing each of their matches, and each of the other matches being won, then how many weeks is it before enough points are accumulated, so that each of the 17 remaining teams are out of reach?

      There are (19 − k) weeks remaining and a doomed team could win all their remaining matches, so they would end with 2 + 3(19 − k) = 59 − 3k points.

      And the total number of points to be shared between the 17 remaining teams would be: 561 + 30k.

      This can happen when:

      (561 + 30k) / 17 > 59 − 3k
      561 + 30k > 1003 − 51k
      81k > 442
      k > 5.46…

      i.e. after the 6th week of the second half of the tournament, at the earliest.

      There would then be 13 weeks remaining, so a doomed team that had a sudden change of fortune could finish with 2 + 3×13 = 41 points. But by that stage in the tournament 561 + 30×6 = 741 points could have been scored by the remaining 17 teams, which is enough for each of them to have accumulated at 43 points each. So the doomed teams can indeed be doomed to relegation.

      Now after three more weeks, i.e. after the 9th week of the second half of the tournament, with 10 weeks remaining, the championship was determined. So the team with the most points must be more than 30 points ahead of the next highest team.

      If we go back to 6th week of the second half of the tournament, then 16 of the 17 non-doomed teams could have 42 points, and the other team could have 69 points. So they are 27 points ahead.

      If they win the following 2 weeks, and the week after that they draw (as we are told in the puzzle text), then after the 9th week they have 76 points, and in order to be unassailable the next highest team can have no more than 45.

      So now we need to make sure none of the other 16 teams can get more than 45 points by the end of week 9. An easy way is to suppose all the matches apart from the ones involving the future champions are drawn.

      Then at the end of the 7th week, the best any of the 16 challengers can do is 43 points. The future champions have 72 points, and there are 12 weeks remaining, so they are assailable.

      At the end of the 8th week, the best any of the challengers can do is 44 points. The future champions have 75 points, and there are 11 weeks remaining, so they are still assailable.

      At the end of the 9th week, the best any of the challengers can do is 45 points. The future champions have 76 points, and there are 10 weeks remaining, so they are now unassailable.

      So this is a viable scenario for the puzzle.

      Solution: The top team had 76 points, and the next highest team had 45 points.

      Like

      • John Crabtree's avatar

        John Crabtree 5:14 pm on 19 June 2020 Permalink | Reply

        This teaser just works. After 6 weeks of the second half, 16 teams have 42 points and one has 69, ie a total of 741 for those teams and the maximum possible.

        Like

  • Unknown's avatar

    Jim Randell 5:27 pm on 9 April 2020 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 3003: All that glitters 

    From The Sunday Times, 12th April 2020 [link] [link]

    My aunt has a collection of sovereigns, and she set me a challenge:

    “You can have the coins if you can work out the dates, which (in increasing order) are equally spaced and all in the 20th century. The number of coins is an odd prime. The highest common factor of each pair of dates is an odd prime. The sum of the number of factors of each of the dates (including 1 and the date itself) is an odd prime.”

    I worked out the dates, though the gift was much less valuable than I’d hoped.

    What were the dates?

    [teaser3003]

     
    • Jim Randell's avatar

      Jim Randell 5:46 pm on 9 April 2020 Permalink | Reply

      I assumed the dates we are looking for are the years in the 20th century for each coin.

      This Python program runs in 93ms.

      Run: [ @repl.it ]

      from enigma import (primes, subsets, irange, inf, gcd, tau, printf)
      
      primes.extend(100)  # primes up to 100
      
      # check a number is an odd prime
      check = lambda n: n > 2 and n in primes
      
      # choose years for the first 2 coins
      for (a, b) in subsets(irange(1901, 1999), size=2):
        if not check(gcd(a, b)): continue
      
        # consider a sequence with n terms
        d = b - a
        for n in primes.irange(3, inf):
          z = a + (n - 1) * d
          if z > 2000: break
          s = list(irange(a, z, step=d))
      
          # gcd of each pair is an odd prime
          if not all(check(gcd(x, y)) for (x, y) in subsets(s, size=2)): break
      
          # sum of the number of divisors of each year is an odd prime
          if not check(sum(tau(x) for x in s)): continue
      
          # output solution
          printf("a={a} b={b}, d={d} -> n={n}: {s}")
      

      Solution: The dates of the coins were: 1903, 1936, 1969.


      Manually (as suggested by Robert):

      Most number have divisors that come in pairs, so have an even number of divisors. The exception is the square numbers, which have an odd number of divisors (see: Puzzle #08).

      So, in order for the sum of the divisors of the dates to be odd, the list of dates must include an odd number of square numbers. And in the range 1901 – 2000 there is only one square number, 1936. So that must be one of the dates.

      1936 factorises as: (2^4)(11^2), so the other dates must have a GCD with 1936 of 11.

      For numbers less than 1936, we get: 1925, 1903. For numbers greater than 1936 we get: 1947, 1969, 1991.

      Looking for arithmetic sequences containing 1936, with a number of elements that is an odd prime we get:

      d=11: (1925, 1936, 1947); divisor sum = 35
      d=33: (1903, 1936, 1969); divisor sum = 23

      Only the second of these has a divisor sum that is prime, and gcd(1903, 1969) = 11 so this satisfies all the required conditions and gives the answer.

      Like

    • Robert Brown's avatar

      Robert Brown 9:08 pm on 9 April 2020 Permalink | Reply

      The only numbers with odd numbers of factors are perfect squares. There is only one of these in the 20th century, and that date has only has one factor >1 that’s an odd prime. Quite easy to find the answer by inspection.

      Like

  • Unknown's avatar

    Jim Randell 8:59 am on 9 September 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2802: That’s the ticket! 

    From The Sunday Times, 5th June 2016 [link] [link]

    Alan, Betty and Charlie each chose a different set of six numbers (from 1 to 49) for their lottery ticket. In each case the product of the six numbers was a perfect square and also each set of six numbers used each of the digits 0 to 9 exactly once.

    Alan won the lottery by getting all six numbers correct. Betty and Charlie also got prizes because they each had at least three numbers correct.

    What were Alan’s six numbers?

    [teaser2802]

     
    • Jim Randell's avatar

      Jim Randell 8:59 am on 9 September 2019 Permalink | Reply

      We have six numbers (between 1 and 49) that between them use 10 digits (each of the digits 0-9 exactly once). So four of the numbers must have 2 digits, and their tens digits are all different, so the set of six numbers is of the form (alphametically):

      a, b, 1c, 2d, 3e, 4f

      where a, b, c, d, e, f are the digits 0, 5, 6, 7, 8, 9 (in some order).

      It turns out there are only three possible sets of six numbers that use the digits 0-9 exactly once and multiply together to give a square. Fortunately one of them shares 3 or more numbers with the other two, so this gives us A’s numbers.

      This Python program runs in 36ms.

      Run: [ @repl.it ]

      from enigma import subsets, multiply, is_square, printf
      
      # find possible sets of numbers
      ss = list()
      for (a, b, c, d, e, f)  in subsets((0, 5, 6, 7, 8, 9), size=len, select="P"):
        if not (0 < a < b): continue
        s = (a, b, 10 + c, 20 + d, 30 + e, 40 + f)
        # we only want sets whose product is a perfect square
        if not is_square(multiply(s)): continue
        ss.append(set(s))
        printf("{s}")
      
      # now choose a set for A
      for A in ss:
        # and find other sets that share at least 3 numbers
        BC = list(s for s in ss if s != A and len(A.intersection(s)) > 2)
        if len(BC) > 1:
          printf("A={A}, BC={BC}", A=sorted(A), BC=list(map(sorted, BC)))
      

      Solution: Alan’s numbers were: 8, 9, 16, 27, 30, 45.

      There are only two options for Betty and Charlie:

      5, 8, 16, 27, 30, 49 = 4 matched numbers
      8, 9, 15, 27, 36, 40 = 3 matched numbers

      Like

    • GeoffR's avatar

      GeoffR 9:47 am on 19 September 2019 Permalink | Reply

      
      % A Solution in MiniZinc
      include "globals.mzn";
      
      % Let digits used be (a, b, cd, ef, gh, ij) for the six numbers
      
      predicate is_sq(var int: y) =
        let {
           var 1..ceil(sqrt(int2float(ub(y)))): z
        } in
         z*z = y;
      
      var 1..9:a; var 1..9:b; var 1..9:c; var 0..9:d;
      var 1..9:e; var 0..9:f; var 1..9:g; var 0..9:h;
      var 1..9:i; var 0..9:j;
      
      var 10..49: cd = 10*c + d;
      var 10..49: ef = 10*e + f;
      var 10..49: gh = 10*g + h;
      var 10..49: ij = 10*i + j;
      
      % six numbers used each of the digits 0 to 9 exactly once
      var set of int: all_dig = {a, b, c, d, e, f, g, h, i, j};
      constraint all_dig = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
      
      % product of six numbers is a square
      constraint is_sq(a * b * cd * ef * gh * ij);
      
      % put six numbers in order
      constraint increasing ([a, b, cd, ef, gh, ij]);
      
      solve satisfy;
      
      output [" Six Numbers are " ++ show([a, b, cd, ef, gh, ij]) ];
      
      % First two solutions are for Betty and Charlie
      % Six Numbers are [5, 8, 16, 27, 30, 49] - 4 nos same as Alan(8,16,27,30)
      %  ----------
      % Six Numbers are [8, 9, 15, 27, 36, 40] - 3 nos same as Alan (8,9,27)
      % ----------
      % Six Numbers are [8, 9, 16, 27, 30, 45] -  Alan's six numbers
      % ----------
      % ========== 
      

      Like

  • Unknown's avatar

    Jim Randell 5:03 pm on 9 May 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2955: Go forth and multiply 

    From The Sunday Times, 12th May 2019 [link] [link]

    Adam and Eve have convex hexagonal gardens whose twelve sides are all the same whole number length in yards. Both gardens have at least two right-angled corners and the maximum possible area this allows. Each garden has a path from corner to corner down an axis of symmetry. Adam multiplies the sum of the path lengths by the difference of the path lengths (both in yards) and Eve squares Adam’s answer, getting a perfect fifth power with no repeated digit.

    What was Eve’s answer?

    See also: Teaser 2946.

    [teaser2955]

     
    • Jim Randell's avatar

      Jim Randell 5:28 pm on 9 May 2019 Permalink | Reply

      Once you’ve worked out the shapes involved, you find that Eve’s answer is 8x^4, and a simple program (or a simple guess) lets us find the appropriate answer.

      Run: [ @repl.it ]

      from enigma import (irange, inf, is_duplicate, is_power, printf)
       
      # consider the length of the side
      for x in irange(1, inf):
        E = 8 * x**4
        if E > 9876543210: break
        if is_duplicate(E): continue
        if not is_power(E, 5): continue
        printf("E={E} [x={x}]")
      

      Solution: Eve’s answer was 32768.

      Like

      • Jim Randell's avatar

        Jim Randell 9:08 am on 12 May 2019 Permalink | Reply

        Here’s the analysis to work out the formula for Eve’s answer:

        If we consider a hexagon (with sides of unit length) that has a right angle at a given vertex, then we can’t have another right angle at an adjacent vertex, as it becomes impossible to construct a convex hexagon if we do.

        So, we need only consider a pair of right angles separated by 1 or 2 intermediate vertices.

        Taking the case with 2 intermediate vertices we get a hexagon that looks like this:

        The length of the diagonal being (1 + √2).

        In the case with only 1 intermediate vertex we get a hexagon that looks like this:

        If the angle XYZ is θ, then the area of the triangle XYZ is given by:

        area(XYZ) = ((√2)/2)sin(θ)

        which is at a maximum when sin(θ) = 1, i.e. θ = 90°.

        And the length of the diagonal d = √3.

        So, for hexagons with side x, the two diagonals have lengths:

        (1 + √2)x
        (√3)x

        Adam’s value (the sum multiplied by the difference) is:

        A = (1 + √2 + √3)x(1 + √2 − √3)x
        A = 2(√2)x²

        And Eve’s value is the square of this:

        E = 8x⁴

        And we are told E is an exact power of 5.

        Choosing x = 8 gives E = 8⁵ = 32768, which has five different digits as required.

        Like

        • Jim Randell's avatar

          Jim Randell 10:46 pm on 12 May 2019 Permalink | Reply

          For completeness:

          The general case of the first hexagon (with right angles separated by two vertices) is a shape like this:

          The red line bisects the hexagon into two identical shapes (by rotation), but in general is not a line of reflective symmetry.

          Again the area of the triangle XYZ is given by the formula:

          area(XYZ) = ((√2)/2)sin(θ)

          and so the maximum area is achieved when sin(θ) = 1, i.e. θ = 90°.

          Which gives us the diagram originally presented (where the red line is a line of reflective symmetry).

          So both gardens have the same area, being composed of two (1, 1, √2) triangles and two (1, √2, √3) triangles. Giving a total area of (1 + √2).

          Like

  • Unknown's avatar

    Jim Randell 12:16 am on 10 March 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2946: Pentagonal gardens 

    From The Sunday Times, 10th March 2019 [link] [link]

    Adam and Eve have convex pentagonal gardens consisting of a square lawn and paving. Both gardens have more than one right-angled corner. All the sides of the gardens and lawns are the same whole number length in metres, but Adam’s garden has a larger total area. Eve has worked out that the difference in the areas of the gardens multiplied by the sum of the paved areas (both in square metres) is a five-digit number with five different digits.

    What is that number?

    [teaser2946]

     
    • Jim Randell's avatar

      Jim Randell 1:16 am on 10 March 2019 Permalink | Reply

      If I’ve understood this correctly there are only two ways to construct the gardens, and this gives a fairly limited set of integer sides. And only one of those gives a viable 5-digit number.

      I worked out 2 possible shapes for the gardens, where the lawn forms most of the perimeter:

      To make calculating the area easier I have split the lawn of A’s garden in two and inserted the paved area between. The areas are the same as if the lawn was a contiguous square.

      If we suppose the line segments making up the perimeter of the gardens are units, then both squares are unit squares and both triangles have a base of length 1.

      A’s triangle has a height of √(7)/2 and an area of √(7)/4. E’s triangle has a height of √(3)/2 and an area of √(3)/4.

      The difference in the total areas of the gardens is:

      (1 + √(7)/4) − (1 + √(3)/4) = (√7 − √3) / 4

      The sum of the paved areas is:

      √(7)/4 + √(3)/4 = (√7 + √3) / 4

      Multiplying these together we get:

      (√7 + √3) × (√7 − √3) / (4 × 4) = 1 / 4

      So, if the gardens were all of side x, the number N would be:

      N = (x^4) / 4

      For a 5-digit value for N there are only a few values of x to try, and this can be completed manually or programatically.

      This Python program runs in 77ms.

      Run: [ @repl.it ]

      from enigma import (irange, div, is_duplicate, printf)
      
      # consider 5 digit values for N
      for x in irange.round(pow(4 * 10000, 0.25), pow(4 * 99999, 0.25)):
        N = div(pow(x, 4), 4)
        if N is None or is_duplicate(N): continue
        # output solution
        printf("x={x} N={N}")
      

      Solution: The number is 16384.

      Like

      • Jim Randell's avatar

        Jim Randell 8:55 am on 10 March 2019 Permalink | Reply

        I’m pretty sure these are the only two possible shapes.

        If you imagine trying to form a set of 5 equal length linked rods into a convex pentagon with more than one right angle, then it is not possible with 3 right angles, so there must be exactly 2 right angles. And these are either on adjacent vertices or have one vertex between them.

        Either way, the remaining rods are forced into unique positions, giving the shapes A and E.

        Although note that with A there are many ways that a unit square can fit inside the pentagon (not necessarily touching the perimeter).

        Like

  • Unknown's avatar

    Jim Randell 11:44 am on 12 February 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2779: New Year Party 

    From The Sunday Times, 27th December 2015

    → See: [ Teaser 2779: New Year Party at Enigmatic Code ]

    [teaser2779]

     
  • Unknown's avatar

    Jim Randell 11:41 am on 12 February 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2773: King Lear III 

    From The Sunday Times, 15th November 2015

    → See: [ Teaser 2773: King Lear III at Enigmatic Code ]

    [teaser2773]

     
  • Unknown's avatar

    Jim Randell 11:37 am on 12 February 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2759: King Lear II 

    From The Sunday Times, 9th August 2015

    → See: [ Teaser 2759: King Lear II at Enigmatic Code ]

    [teaser2759]

     
  • Unknown's avatar

    Jim Randell 8:27 pm on 7 February 2019 Permalink | Reply
    Tags: by: Nick MacKinnon   

    Teaser 2942: What do points make? 

    From The Sunday Times, 10th February 2019 [link] [link]

    In the Premier League table a team’s points are usually roughly equal to their goals scored (Burnley were an interesting exception in 2017-18). That was exactly the case in our football league after the four teams had played each other once, with 3 points for a win and 1 for a draw.

    A ended up with the most points, followed by B, C and D in that order. Fifteen goals had been scored in total, and all the games had different scores. The best game finished 5-0, and the game BvD had fewer than three goals.

    What were the results of B’s three games (in the order BvA, BvC, BvD)?

    [teaser2942]

     
    • Jim Randell's avatar

      Jim Randell 11:38 am on 8 February 2019 Permalink | Reply

      I think this puzzle could have been worded more clearly.

      I took the first part to mean we are looking for situations where each team has exactly the same number of points as the number of goals scored by that team. And that the “best game finished 5-0” means that that game had the most goals scored altogether (i.e. the other games had no more than 4 goals scored in total). I took the fact that all matches had different scores to mean that you couldn’t have (for example) one game with a score of 2-0 and another with a score of 0-2.

      This program uses the [[ Football() ]] helper class from the enigma.py library. It looks for possible games for a team that can give the same number of points as the number of goals scored by that team, and then chooses outcomes for the four teams that satisfy the remaining conditions of the puzzle. It runs in 340ms.

      Run: [ @replit ]

      from itertools import (product, combinations)
      from enigma import (defaultdict, Football, ordered, printf)
      
      # scoring system
      football = Football(games='wdl', points=dict(w=3, d=1))
      
      # possible scores (a 5-0 and then no more than 4 goals in any match)
      scores = dict()
      scores['w'] = set([(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (2, 1), (3, 1)])
      scores['d'] = set([(0, 0), (1, 1), (2, 2)])
      scores['l'] = set((x, y) for (y, x) in scores['w'])
      
      # record possible games by points (= goals for)
      ss = defaultdict(list)
      
      # consider outcomes for three matches for team T against X, Y, Z
      for (TX, TY, TZ) in football.games(repeat=3):
      
        # make the table for team T
        T = football.table([TX, TY, TZ], [0, 0, 0])
      
        # make possible score lines that give "goals for" = "points"
        for (sTX, sTY, sTZ) in product(scores[TX], scores[TY], scores[TZ]):
      
          (fT, aT) = football.goals([sTX, sTY, sTZ], [0, 0, 0])
      
          if not (fT == T.points): continue
      
          ss[fT].append((sTX, sTY, sTZ))
      
      # choose possible points (= goals for) for A, B, C, D
      for (pA, pB, pC, pD) in combinations(sorted(ss.keys(), reverse=1), 4):
      
        # but points = goals for, and the total number of goals is 15
        if not (pA + pB + pC + pD == 15): continue
      
        # choose matches for B
        for (BA, BC, BD) in ss[pB]:
      
          # B vs D has less than 3 goals scored
          if not (sum(BD) < 3): continue
      
          # choose matches for A
          for (AB, AC, AD) in ss[pA]:
            if not (AB == BA[::-1]): continue
      
            # choose matches for C
            for (CA, CB, CD) in ss[pC]:
              if not (CA == AC[::-1] and CB == BC[::-1]): continue
      
              # check matches for D
              if not ((AD[::-1], BD[::-1], CD[::-1]) in ss[pD]): continue
      
              # all games have different scores
              s = set(ordered(*x) for x in (AB, AC, AD, BC, BD, CD))
              if not (len(s) == 6): continue
      
              # there is a 5-0 game
              if not ((0, 5) in s): continue
      
              printf("AB={AB} AC={AC} AD={AD} BC={BC} BD={BD} CD={CD}, A={pA} B={pB} C={pC} D={pD}")
      

      Solution: The scores in B’s games are: B vs A = 1-2; B vs C = 2-2; B vs D = 1-0.

      It turns out that the fact that there is a 5-0 game means that there are only 10 goals to distribute between the remaining 5 matches, and there are no further solutions if games with more than 4 goals scored are considered, so it is enough to know that there is a 5-0 score.

      If we allow “mirror” scores (e.g. one game with a score of 2-0 and another with a score of 0-2), then there are no further solutions either. (Although if we allow repeated scores then there are additional solutions).

      If we relax the conditions that the number of points is exactly the same as the number of goals scored then there are multiple solutions, even if they must be within 1 of each other.

      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