Tagged: by: Lt-Col C E Booth-Jones Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 9:29 am on 5 January 2021 Permalink | Reply
    Tags: by: Lt-Col C E Booth-Jones   

    Brain-Teaser 658: Fiendish device 

    From The Sunday Times, 17th February 1974 [link] [link]

    “Moriarty speaking”, said the voice on the telephone to the Prime Minister. “As you have rejected my demands, a hidden bomb with destroy London. I’m particularly pleased with the detonating device”, he went on, chuckling fiendishly, “it’s designed to give me time to get away before the explosion. There are 60 switches (all turned OFF at the moment) arranged in a ring so that No. 60 is next to No. 1. Whenever any switch changes from ON to OFF it causes the following switch to change over virtually instantaneously (from OFF to ON or vice-versa). As soon as I put down this phone I’ll activate the device. This will automatically put switch No. 1 to ON, then one minute later to OFF, then one minute later still to ON, carrying on in this way after each minute changing switch No. 1 over. As soon as every switch has remained in the OFF position for 10 seconds simultaneously the bomb explodes. So goodbye now — for ever!”

    The Prime Minister turned anxiously to Professor D. Fuse who had been listening in. “When will the activating device set off the bomb?” he asked.

    What was the Professor’s reply?

    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.

    [teaser658]

     
    • Jim Randell's avatar

      Jim Randell 9:29 am on 5 January 2021 Permalink | Reply

      If there were only 3 switches, this what would happen:

      1 2 3
      1 0 0 (0m)
      0 1 0 (1m)
      1 1 0 (2m)
      0 0 1 (3m)
      1 0 1 (4m)
      0 1 1 (5m)
      1 1 1 (6m)
      1 0 0 (7m)

      If we read the switches backwards we see the system of switches operates as a binary counter starting at 001 (= 1) and counting up to 111 (= 7) after 6 minutes.

      After 7 minutes the counter would reach 8 = (000 + overflow), but the switches are arranged in a circle, so the overflow bit feeds into the least significant bit of the counter, so state 8 corresponds to state 1 (= 001) and we are back where we started.

      The counter cycles through the non-zero states 1-7 every 7 minutes, so never achieves state 0 and the bomb will never go off.

      So, with 60 switches we have a 60-bit counter which cycles through the states 1 – (2^60 − 1) every 1152921504606846975 minutes (= 2.2e+12 years), without ever reaching zero.

      Solution: The Professor’s reply is: “Never”.

      Like

  • Unknown's avatar

    Jim Randell 8:22 am on 9 April 2019 Permalink | Reply
    Tags: by: Lt-Col C E Booth-Jones   

    Brain-Teaser 469: [Safe combination] 

    From The Sunday Times, 24th May 1970 [link]

    Before his retirement, the Master Spy, enigmatic to the last, left instructions for opening his safe and recovering the Top Secret plans for Winning World Domination:

    “The combination is a 7-figure number, the sum of whose digits is 55. The first 4 figures make up a number divisible by 17, the sum of whose digits is also divisible by 17. The last 3 figures make up a number divisible by 7, the sum of whose digits is also divisible by 7.

    By now you should realise that there are 4 possible combinations. Since 3 of these all detonate a booby-trap, I’d better warn you that the correct number has no figure appearing more than 3 times”

    What is the combination of the safe?

    This puzzle was originally published with no title.

    [teaser469]

     
    • Jim Randell's avatar

      Jim Randell 8:23 am on 9 April 2019 Permalink | Reply

      We can treat this puzzle as a collection of alphametic expressions that can be handled by the [[ SubstitutedExpression() ]] solver from the enigma.py library.

      The following run file executes in 324ms.

      Run: [ @repl.it ]

      #! python3 -m enigma -rr
      
      # suppose the combination number is: ABCDEFG
      
      SubstitutedExpression
      
      --distinct=""
      --answer="ABCDEFG"
      
      # the digits sum to 55
      "A + B + C + D + E + F + G = 55"
      
      # the first four digits (and their sum) are divisible by 17
      "ABCD % 17 = 0"
      "(A + B + C + D) % 17 = 0"
      
      # the last three digits (and their sum) are divisible by 7
      "EFG % 7 = 0"
      "(E + F + G) % 7 = 0"
      
      # check no digit appears more than 3 times
      --code="check = lambda *s: all(s.count(d) < 4 for d in set(s))"
      "check(A, B, C, D, E, F, G)"
      

      Solution: The combination is 9979588.

      The four candidate numbers are: 9979777, 9979588, 9979966, 9979399.

      Like

    • GeoffR's avatar

      GeoffR 3:07 pm on 9 April 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;
      
      constraint A >  0 /\ E > 0;
      
      var 1000000..9999999: ABCDEFG = 1000000*A + 100000*B + 10000*C + 1000*D + 100*E + 10*F + G;
      var 1000..9999: ABCD = 1000*A + 100*B + 10*C + D; 
      var 100..999: EFG = 100*E + 10*F + G;
      
      constraint A + B + C + D + E +  F + G == 55;
      
      constraint ABCD mod 17 == 0 /\ (A + B + C + D) mod 17 == 0;
      
      constraint EFG mod 7 == 0 /\ (E + F + G) mod 7 == 0;
      
      solve satisfy;
      
      output [ "Safe combination = " ++ show(ABCDEFG) ];
      
      % Safe combination = 9979966  << has 4 nines
      % Safe combination = 9979777  << has 4 sevens
      % Safe combination = 9979588  << has 3 nines  << the answer 
      % Safe combination = 9979399  << has 4 nines
      % ----------
      % ==========
      % Finished in 240msec
      

      Like

      • Jim Randell's avatar

        Jim Randell 5:18 pm on 9 April 2019 Permalink | Reply

        And we could add the following constraint to narrow the possibilities down to the single answer:

        constraint forall (d in 0..9) (at_most(3, [A, B, C, D, E, F, G], d));
        

        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