Tagged: by: Alan Bergson Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 8:56 am on 20 May 2021 Permalink | Reply
    Tags: by: Alan Bergson   

    Teaser 2792: Easter Teaser 

    From The Sunday Times, 27th March 2016 [link] [link]

    I have written down three numbers and then consistently replaced digits by letters, with different letters for different digits, to give:

    EASTER
    SUNDAY
    TEASER

    In fact the first number is the lowest and one of these numbers is the sum of the other two.

    What is this SUNDAY‘s number?

    [teaser2792]

     
    • Jim Randell's avatar

      Jim Randell 8:56 am on 20 May 2021 Permalink | Reply

      We can get a solution using the [[ SubstitutedExpression ]] solver from the enigma.py library.

      This run file executes in 421ms.

      #! python3 -m enigma -rr
      
      SubstitutedExpression
      
      "abs(SUNDAY - TEASER) = EASTER"
      
      "E < S" # EASTER < SUNDAY
      "E < T" # EASTER < TEASER
      
      --answer="SUNDAY"
      

      Solution: SUNDAY = 816270.


      For a faster solution we can use the (experimental) [[ SubstitutedExpression.split_sum() ]] solver.

      The following Python program runs in 58ms.

      Run: [ @replit ]

      from enigma import SubstitutedExpression, printf
      
      # solve the sum <expr>
      def check(expr, *extra):
        p = SubstitutedExpression.split_sum(expr, extra=extra, answer="SUNDAY").solver()
        for (s, ans) in p.solve(verbose=0):
          printf("SUNDAY = {ans} [{expr} / {s}]", s=p.substitute(s, expr))
      
      # check the two possibilities
      check('EASTER + SUNDAY = TEASER', 'E < S')
      check('EASTER + TEASER = SUNDAY', 'E < T')
      

      There is only one possible solution even without the information that EASTER is the lowest number. So the [[ E < S ]] and [[ E < T ]] clauses could be removed.

      Like

    • GeoffR's avatar

      GeoffR 9:58 am on 31 May 2021 Permalink | Reply

      % A Solution in MiniZinc
      include "globals.mzn";
      
      var 1..9: E; var 0..9: A; var 1..9: S;
      var 1..9: T; var 0..9: R; var 0..9: U;
      var 0..9: N; var 0..9: D; var 0..9: Y;
      
      constraint all_different ([E,A,S,T,R,U,N,D,Y]);
      
      var 100000..999999: EASTER = 100000*E + 10000*A + 1000*S + 100*T + 10*E + R;
      var 100000..999999: SUNDAY = 100000*S + 10000*U + 1000*N + 100*D + 10*A + Y;
      var 100000..999999: TEASER = 100000*T + 10000*E + 1000*A + 100*S + 10*E + R;
      
      constraint EASTER < SUNDAY /\ EASTER < TEASER;
      constraint EASTER + TEASER == SUNDAY \/ EASTER + SUNDAY == TEASER;
      
      solve satisfy;
      output ["SUNDAY's number = " ++ show(SUNDAY) ];
      % SUNDAY's number = 816270
      % ----------
      % ==========
      
      
      

      Like

  • Unknown's avatar

    Jim Randell 11:59 am on 17 September 2020 Permalink | Reply
    Tags: by: Alan Bergson   

    Teaser 2736: HS2 

    From The Sunday Times, 1st March 2015 [link] [link]

    Last night I dreamt that I made a train journey on the HS2 line. The journey was a whole number of miles in length and it took less than an hour. From the starting station the train accelerated steadily to its maximum speed of 220 mph, then it continued at that speed for a while, and finally it decelerated steadily to the finishing station. If you took the number of minutes that the train was travelling at a steady speed and reversed the order of its two digits, then you got the number of minutes for the whole journey.

    How many miles long was the journey?

    [teaser2736]

     
    • Jim Randell's avatar

      Jim Randell 12:00 pm on 17 September 2020 Permalink | Reply

      If the time at constant speed is AB minutes, then the total time is BA minutes, and:

      AB < BA < 60

      So:

      0 < A < B < 6

      The maximum speed is 220 mph = 11/3 miles per minute.

      From the velocity/time graph we get the total distance d is:

      d = (121/6)(A + B)

      From which we see (A + B) must be divisible by 6, so (A, B) = (1, 5) or (2, 4), and d = 121.

      A simple Python program can verify this:

      Run: [ @replit ]

      from enigma import (subsets, irange, div, printf)
      
      for (A, B) in subsets(irange(1, 5), size=2):
        d = div(121 * (A + B), 6)
        if d is not None:
          printf("d={d} [A={A} B={B}]")
      

      Solution: The journey was 121 miles long.

      Like

  • Unknown's avatar

    Jim Randell 9:36 am on 7 July 2020 Permalink | Reply
    Tags: by: Alan Bergson   

    Teaser 2663: Missed the plot 

    From The Sunday Times, 6th October 2013 [link] [link]

    My friend has a triangular vegetable plot, all sides being whole numbers of metres. Coincidentally, the dimensions of the plot are such that its perimeter (in metres) is the same as its area (in square metres). Also, the length of one of the sides is the average of the lengths of the other two sides.

    What are the lengths of the sides of the plot?

    [teaser2663]

     
    • Jim Randell's avatar

      Jim Randell 9:37 am on 7 July 2020 Permalink | Reply

      The triangle has sides of integer lengths (a, b, c) such that b = (a + c)/2.

      We can use Heron’s Formula [ @wikipedia ] to equate the area of the triangle with the perimeter, which gives us some restrictions on the sides of the triangle.

      However, we have encountered “equable” triangles before in Enigma 364, and generated a list of the 5 equable triangles, from which we can easily pick out the one that has one side that is an average of the other two.

      I also wrote code to generate k-equable triangles (integer sided triangles where the area is k times the perimeter), and that code can be reused here:

      Run: [ @repl.it ]

      from enigma import irange, isqrt, divc, divf, printf
      
      # find all triangles with integer sides where area = k . perimeter
      def triangles(k=1):
        K = 4 * k * k
        for p in irange(1, isqrt(3 * K)):
          for q in irange(max(p, divc(K + 1, p)), divf(3 * K, p)):
            (r, z) = divmod(K * (p + q), p * q - K)
            if r < q: break
            if z == 0: yield (p + q, p + r, q + r)
      
      # consider 1-equable triangles
      for (a, b, c) in triangles(1):
        if b - a == c - b:
          printf("a={a} b={b} c={c}")
      

      Solution: The lengths of the sides of the plot are: 6m, 8m, 10m.

      Like

    • GeoffR's avatar

      GeoffR 10:54 am on 8 July 2020 Permalink | Reply

      
      for a in range (3, 25):
        for b in range (a+1, 25):
          for c in range(b+1, 25):
            # a < b < c and 2 * b = a + c
            if 2 * b != a + c: continue
            # Square of perimeter
            perim_sq = (a + b + c) ** 2
            # Area squared formula is based in Heron's formula
            area_sq = 1/16 *( 4*a*a*b*b - (a*a + b*b - c*c)**2)
            if perim_sq == area_sq:
              print(f"Length of sides are {a}, {b} and {c}m")
      
      # Length of sides are 6, 8 and 10m
      

      A (5,12,13) triangle has the area equal to the perimeter numerically, but does not have one side as the average of the other two sides.

      Like

  • Unknown's avatar

    Jim Randell 7:01 am on 26 March 2019 Permalink | Reply
    Tags: by: Alan Bergson   

    Brainteaser 1505: Waste not … 

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

    The “tangram” is an ancient Chinese puzzle. It consists of seven pieces which can be formed into a square (as shown) and into many other artistic shapes.

    The middle-sized triangle, the square and the parallelogram are all twice the area of the smaller triangles, and half the area of the larger ones. All the angles are 45, 90 or 135 degrees. And in my version the lengths of the shorter sides of the largest triangles are 7 cm.

    I have a thin rectangular sheet of card 70 cm by 91 cm from which I wish to cut as many such sets of tangrams as possible with the minimum amount of wastage.

    How many complete sets can I make?

    The text of this puzzle is taken from the book Brainteasers (2002), so may differ from the puzzle originally published in the newspaper.

    [teaser1505]

     
    • Jim Randell's avatar

      Jim Randell 7:03 am on 26 March 2019 Permalink | Reply

      The Tangram square shown, has sides measuring 7√2 cm. Which gives it an area of 98 cm².

      The 70 cm × 91 cm piece of card has an area of 6370 cm².

      So there is potentially enough card to make 65 complete sets with no wastage.

      However the square shown does will not fit into the length or width of the card an exact number of times.

      My solution is cut the card into 7 cm × 7 cm squares. This divides the card into 10 × 13 = 130 squares.

      We then rearrange the Tangram into two squares:

      These squares also measure 7 cm × 7cm.

      So, we then cut 65 of the squares using pattern A, and the remaining 65 sets using pattern B, giving us 65 complete Tangram sets.

      Solution: We can make 65 sets, with no wastage.

      Like

    • Lise Andreasen's avatar

      Lise Andreasen 7:28 am on 19 April 2024 Permalink | Reply

      Neat.

      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