Tagged: by: B T Izzard Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 10:16 am on 14 May 2024 Permalink | Reply
    Tags: by: B T Izzard   

    Brain-Teaser 950: Magic moments 

    From The Sunday Times, 5th October 1980 [link]

    Joe decided to utilise the garden see-saw to demonstrate the principles of balance, and of moments to, his family. Alf, Bert, Charlie, Doreen, Elsie and Fiona weighed 100, 80, 70, 60, 50 and 20 kilos respectively. The seesaw had three seats each side, positioned 1, 2 and 3 metres from the centre.

    They discovered many ways of balancing using some or all of the family.

    In one particular combination, with at most one person on each seat, one of the family not on the seesaw observed that the sum of the moments of all of the people on the seesaw was a perfect square.

    “That’s right”, said Joe, “but, as you can see, it doesn’t balance — and what’s more, there’s nowhere you can sit to make it balance”.

    “Wrong”, was the reply. “I could sit on someone’s lap”.

    “True,” said Joe, “but only if you sit at the end”.

    Which two would then be sitting together, and who else, if anyone, would be on the same side of the see-saw?

    [To find the moment due to each person, multiply their distance from the centre by their weight. The sum of the moments on one side should equal the sum of those on the other if balance is to be achieved].

    This puzzle is included in the book The Sunday Times Book of Brainteasers (1994).

    [teaser950]

     
    • Jim Randell's avatar

      Jim Randell 10:16 am on 14 May 2024 Permalink | Reply

      Participants can be uniquely identified by their weights.

      This Python program finds possible seating arrangements on the see-saw.

      It runs in 72ms. (Internal runtime is 13ms).

      Run: [ @replit ]

      from enigma import (subsets, is_square, div, printf)
      
      # weights and positions
      weights = [100, 80, 70, 60, 50, 20]
      poss = [+1, +2, +3, -1, -2, -3]
      
      # there is at least one member not seated
      for ws in subsets(weights, min_size=2, max_size=len(weights) - 1, select='C'):
        # allocate positions (including +3)
        for ps in subsets(poss, size=len(ws), select='P'):
          if +3 not in ps: continue
          # find the total sum of the moments
          ms = sum(w * abs(p) for (w, p) in zip(ws, ps))
          if not is_square(ms): continue
          # weight required at +3 to balance the see-saw
          x = -sum(w * p for (w, p) in zip(ws, ps))
          w = div(x, +3)
          # is it the weight of a missing person?
          if not (w in weights and w not in ws): continue
          # output solution
          printf("ws={ws} ps={ps} ms={ms} x={x} w={w}")
      

      Solution: Doreen would join Fiona at the end of the see-saw. Elsie is also seated on the same side.

      The seating arrangement is as follows:

      Without D the moments are (kg.m):

      L = 70×3 + 80×1 = 290
      R = 20×3 + 50×1 = 110

      They don’t balance, but they do sum to 400 = 20^2.

      With D the moments on the right become:

      R = (20 + 60)×3 + 50×1 = 290

      and the see-saw balances.

      Like

    • Frits's avatar

      Frits 2:26 pm on 14 May 2024 Permalink | Reply

        
      from enigma import express
      from itertools import product
       
      # weights and positions
      weights = [100, 80, 70, 60, 50, 20]
      names = ["Alf", "Bert", "Charlie", "Doreen", "Elsie", "Fiona"]
      
      # possible squares divisible by 10 
      for sq in [100, 400, 900]:
        # decompose square into weights
        for e in express(sq, weights, min_q=0, max_q=3):
          # someone is sitting at the end and one place is empty
          if all(x for x in e) or 3 not in e: continue
          # at most one person on each seat
          if any(e.count(i) > 2 for i in range(1, 4)): continue
         
          # one of the family not on the seesaw to sit at the end on someone's lap
          for i, seat in enumerate(e):
            if seat: continue # not an empty seat
            e1 = e[:i] + [3] + e[i + 1:] 
            
            # multiply elements by 1 or -1 times the weight and 
            # see if they sum to zero
            for prod in product([-1, 1], repeat=len([x for x in e1 if x])):
              if prod[0] > 0: continue    # avoid symmetric duplicates
              # weave in zeroes
              p = list(prod)
              p = [p.pop(0) if x else 0 for x in e1]
              
              # is the seesaw in balance?
              if sum([x * y * weights[i] 
                     for i, (x, y) in enumerate(zip(p, e1))]) != 0: continue
              # new persion must be sitting on someone's lap at the end
              someone = [j for j in range(6) if j != i and e1[j] == 3 and 
                                                p[j] == p[i]]
              if not someone: continue
              print(f"{names[i]} would join {names[someone[0]]}",
                    f"at the end ofthe see-saw.")
              oths = [j for j in range(6) if p[j] == p[i] and 
                                             j not in {i, someone[0]}]
              if not oths: continue
              ns = [names[o] for o in oths]
              oths = ns[0] + " is" if len(oths) == 1 else ' and '.join(ns) + " are"
              print(f"{oths} also seated on the same side.")   
      

      Like

  • Unknown's avatar

    Jim Randell 6:02 pm on 15 August 2021 Permalink | Reply
    Tags: by: B T Izzard   

    Brain-Teaser 835: Traffic light entertainment 

    From The Sunday Times, 17th July 1977 [link]

    Newtown High Street has a linked traffic light system which consists of six consecutive sections, each a multiple of one-eighth of a mile, and each terminating in a traffic light.

    The lights are synchronised such that a vehicle travelling at 30 mph will pass each light at the same point in its 26-second operating cycle.

    This cycle can be considered as 13 seconds “stop” (red) and 13 seconds “go”(green).

    Charlie had studied the system and reckoned he could drive much faster than 30 mph and still get through the system without crossing a red light.

    In an experiment Alf, Bert and Charlie entered the first section at the same instant, travelling at 30, 50 and 75 mph respectively, with the first light turning green three seconds later.

    Charlie got through the whole system in less than two minutes without being stopped.

    “I was lucky though”, said Charlie. “I arrived at the last light just as it changed”.

    “My luck was non-existent”, said Bert. “I ran out of petrol after the third light and in any case would have been stopped at the second light had I not lost 10 seconds due to a delay in the second section!”

    What were the lengths of each section in order from the first?

    This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 1 (1980). The puzzle text above is taken from the book.

    [teaser835]

     
    • Jim Randell's avatar

      Jim Randell 6:03 pm on 15 August 2021 Permalink | Reply

      (See also: Enigma 198).

      Using distance units of eighths of a mile. We see that the final light must be less than 20 units away from the start, and the time to travel each unit is:

      A: 30mph = 1 unit in 15s
      B: 50mph = 1 unit in 9s
      C: 75mph = 1 unit in 6s

      And the following conditions hold at the lights:

      A: makes it through all lights at green (and at the same point in the 26s cycle)
      B: makes it through light 1; but is stopped at light 2, however …
      B + 10s: makes it through lights 2 and 3
      C: makes it through all lights at green, but hits light 6 as it is changing.

      The following Python 3 program runs in 50ms.

      Run: [ @replit ]

      from enigma import irange, printf
      
      # 0 - 13 = green, 14 - 25 = red
      def green(t, t0):
        return (t - t0) % 26 < 14
      
      # solve starting with light k
      # k = index of next light
      # ds = length of light controlled sections
      # ts = start time of light "go" period
      def solve(k, ds, ts, A=0, B=0, C=0):
        # calculate times at the current light
        d = ds[-1]
        t = ts[-1]
        A += d * 15
        B += d * 9
        C += d * 6
      
        # at all lights, A and C get green lights 
        if not(green(A, t) and green(C, t)): return
        # at the first light...
        if k == 1:
          # B made it through
          if not(green(B, t)): return
        # at the second light ...
        elif k == 2:
          # B would have been stopped ...
          if green(B, t): return
          # but he arrived 10s late
          if not green(B + 10, t): return
        # at the third light ...
        elif k == 3:
          # B passed at green, 10s late
          if not green(B + 10, t): return
        # at the sixth light ...
        elif k == 6:
          # C arrived just as they changed
          if (C - t) % 13 != 0: return
      
        # are we done?
        if k == 6:
          # return the distances
          yield ds
        else:
          # move on to the next light
          for x in irange(1, 14 + k - sum(ds)):
            for z in solve(k + 1, ds + [x], ts + [t + 15 * x], A, B, C): yield z
      
      # consider distance to light 1
      for d in irange(1, 14):
        # solve the puzzle (first light goes green at t=3)
        for ds in solve(1, [d], [3]):
          printf("distances = {ds}")
      

      Solution: The lengths of the sections (in miles) are: 1st = 1/8; 2nd = 1/4; 3rd = 3/8; 4th = 1/8; 5th = 1/4; 6th = 1/8.

      The total length of the sections is 10/8 miles (= 1.25 miles), so C completes the course in 60s (= 1m) and A in 150s (= 2m30s).

      Here is a diagram showing the progress of A, B and C:

      A arrives at each light just before it changes to red. And C ends his journey by heading towards a red light at 75mph, which (fortunately) changes to green just as he reaches it.

      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