Tagged: by: J Cameron Toggle Comment Threads | Keyboard Shortcuts

  • Unknown's avatar

    Jim Randell 12:10 pm on 26 May 2020 Permalink | Reply
    Tags: by: J Cameron   

    Brain-Teaser 520: [Picnic allocations] 

    From The Sunday Times, 30th May 1971 [link]

    “What’s inside it?” asked the Mole wriggling with curiosity.

    “There’s cold chicken inside it”, replied the Rat briefly: “cold-tongue-cold-ham-cold-beef-pickled-gherkins-salad-french-rolls-cress-sandwiches-potted-meat-ginger-beer-lemonade-soda-water…”

    “Oh, stop”, cried the Mole in ecstasies. “This is too much for one picnic. We can have another tomorrow on what’s left”.

    “Do you really think so?” inquired the Rat seriously. “Let’s see. There’s only salad-pickled-gherkins-french-rolls-and-soda-water enough for two days: so if we have ham today we’ll have beef tomorrow; if we have potted meat today we’ll have cress sandwiches tomorrow; and if we have tongue today we’ll have lemonade tomorrow”.

    “If we save the cress sandwiches for tomorrow we’ll have the beef today; if we keep the potted meat for tomorrow we’ll have the ginger beer today; and if we keep the lemonade for tomorrow we’ll have the ham today”. The Mole was entering into the spirit of the thing.

    “In any event we’ll have the lemonade and ginger beer on different days, and likewise the beef and the chicken”, Rat shrieked excitedly.

    “And if we have the chicken and cress sandwiches together, we’ll have the potted meat the day after we have the tongue”. The Mole rolled on his back at the prospect. “And we’ll eat every scrap”.

    Which of the eight items did they save for the second day?

    This puzzle was originally published with no title.

    [teaser520]

     
    • Jim Randell's avatar

      Jim Randell 12:10 pm on 26 May 2020 Permalink | Reply

      The following Python program checks all possible assignments of days to the 8 items in question, and then checks to find which assignments satisfy all the conditions.

      It runs in 71ms (on my new laptop). (Internal runtime is 192µs).

      from enigma import (subsets, implies, printf)
      
      # choose days for the 8 items in question
      for (CC, CT, CH, CB, CS, PM, GB, LE) in subsets((1, 2), size=8, select="M"):
      
        # check the statements:
      
        # R: "if we have ham today we'll have beef tomorrow"
        if not implies(CH == 1, CB == 2): continue
      
        # R: "if we have potted meat today we'll have cress sandwiches tomorrow"
        if not implies(PM == 1, CS == 2): continue
      
        # R: "if we have tongue today we'll have lemonade tomorrow"
        if not implies(CT == 1, LE == 2): continue
      
        # M: "if we save the cress sandwiches for tomorrow we'll have the beef today"
        if not implies(CS == 2, CB == 1): continue
      
        # M: "if we keep the potted meat for tomorrow we'll have the ginger beer today"
        if not implies(PM == 2, GB == 1): continue
      
        # M: "if we keep the lemonade for tomorrow we'll have the ham today"
        if not implies(LE == 2, CH == 1): continue
      
        # R: "we'll have the lemonade and ginger beer on different days ..."
        if not (LE != GB): continue
      
        # R: "... and likewise the beef and the chicken"
        if not (CB != CC): continue
      
        # M: "if we have the chicken and cress sandwiches together, we'll
        # have the potted meat the day after we have the tongue"
        if not implies(CC == CS, PM == CT + 1): continue
      
        # output solution
        printf("CC={CC} CT={CT} CH={CH} CB={CB} CS={CS} PM={PM} GB={GB} LE={LE}")
      

      Solution: The cold beef, potted meat and lemonade was saved for the second day.

      Like

      • John Crabtree's avatar

        John Crabtree 8:10 pm on 25 June 2020 Permalink | Reply

        There are 9 statements for 8 unknowns. If Ch is true for chicken today, and ~Ch is true for chicken tomorrow,then the statements may be written as boolean equations:
        1. H.~B + ~H = 1
        2. P.~Cr + ~P = 1
        3. T.~L + ~T = 1
        4. ~Cr.B + Cr = 1
        5. ~P.G + P = 1
        6. ~L.H + L = 1
        7. L XOR G
        8. B XOR Ch
        9. [(Ch XNOR Cr).~P.T] + (Ch XOR Cr) = 1

        Combining equations 5, 7, 6, 1, 4, 2 and 8 gives
        1 = (~P.G + P).( L XOR G).(~L.H + L).(H.~B + ~H).(~Cr.B + Cr).(P.~Cr + ~P).(B XOR Ch)
        = ~P.G.( L XOR G).(~L.H + L).(H.~B + ~H).(~Cr.B + Cr).(P.~Cr + ~P).(B XOR Ch) +
        ….P.(P.~Cr + ~P).(~Cr.B + Cr).(H.~B + ~H).(~L.H + L).( L XOR G).(B XOR Ch)
        = ~P.G.~L.H.~B.Cr.Ch + P.~Cr.B.~H.L.~G.~Ch
        Combing this with equation 9 gives ~P.G.~L.H.~B.Cr.Ch.T = 1
        Equation 3 is satisfied, but is not required to solve the teaser by this method

        The items to be saved for tomorrow are given by ~B,~L and ~P, ie cold Beef, Lemonade and Potted meat.

        Starting with any assumption other than T or ~T and working through the equations 1-2, and 4-8 in some order and finally 9 gives either a consistent solution,or a contradiction (reductio ad absurdum). If one starts by assuming T, then equation 3 is used before the others. If ~T is assumed, then equation 9 gives Ch.~Cr + ~Ch.Cr = 1, and both conditions have to be checked to show that ~T is not true

        Like

      • Jim Randell's avatar

        Jim Randell 3:12 pm on 15 November 2025 Permalink | Reply

        Or using the [[ SubstitutedExpression ]] solver from the enigma.py library.

        The code generated from the following run file has an internal runtime of 75µs.

        #! python3 -m enigma -rr
        
        SubstitutedExpression
        
        --distinct=""
        --digits="1,2"
        
        --macro="@CC = {A}"  # cold chicken
        --macro="@CT = {B}"  # cold tongue
        --macro="@CH = {C}"  # cold ham
        --macro="@CB = {D}"  # cold beef
        --macro="@CS = {E}"  # cress sandwiches
        --macro="@PM = {F}"  # potted meat
        --macro="@GB = {G}"  # ginger beer
        --macro="@LE = {H}"  # lemonade
        
        # R: "if we have ham today we'll have beef tomorrow"
        "implies(@CH == 1, @CB == 2)"
        
        # R: "if we have potted meat today we'll have cress sandwiches tomorrow"
        "implies(@PM == 1, @CS == 2)"
        
        # R: "if we have tongue today we'll have lemonade tomorrow"
        "implies(@CT == 1, @LE == 2)"
        
        # M: "if we save the cress sandwiches for tomorrow we'll have the beef today"
        "implies(@CS == 2, @CB == 1)"
        
        # M: "if we keep the potted meat for tomorrow we'll have the ginger beer today"
        "implies(@PM == 2, @GB == 1)"
        
        # M: "if we keep the lemonade for tomorrow we'll have the ham today"
        "implies(@LE == 2, @CH == 1)"
        
        # R: "we'll have the lemonade and ginger beer on different days ..."
        "@LE != @GB"
        
        # R: "... and likewise the beef and the chicken"
        "@CB != @CC"
        
        # M: "if we have the chicken and cress sandwiches together, we'll
        # have the potted meat the day after we have the tongue"
        "implies(@CC == @CS, @PM == @CT + 1)"
        
        # output day for each dish
        --template="CC=@CC CT=@CT CH=@CH CB=@CB CS=@CS PM=@PM GB=@GB LE=@LE"
        --solution=""
        --verbose="1-H"
        

        Like

  • Unknown's avatar

    Jim Randell 3:23 pm on 24 October 2019 Permalink | Reply
    Tags: by: J Cameron   

    Brain-Teaser 506: [The sword of Nyarlathotep] 

    From The Sunday Times, 21st February 1971 [link]

    Students of the “Necronomicon” will be pleased to learn that sheet 73-74, missing from the copy at Miskatonic University, has come to light in the manuscript recently bought by the British Museum. On it the mad Arab, Abdul al Hazrad, has written:

    “Cthulhu na fa’t’agn!

    To fashion the sword of Nyarlathotep, take of fair metals for the hilt and the guard and the blade, enough.

    The hilt shall be copper, unless the guard be silver in which case the blade shall be copper unless the hilt is gold.

    The guard shall be copper unless the blade be gold in which case the guard shall be silver unless the hilt is silver.

    The blade shall be gold unless the guard be gold in which case the blade shall be silver unless the hilt is copper.

    Fashion then the sword of Nyarlathotep.”

    Thus: Hilt = ?, Guard = ?, Blade = ?

    This puzzle was originally published with no title.

    [teaser506]

     
    • Jim Randell's avatar

      Jim Randell 3:24 pm on 24 October 2019 Permalink | Reply

      The conditions are expressed in a similar manner, so once the pattern of the text is determined it is easy to express the constraints.

      This Python program examines all the possibilities for the construction. It runs in 81ms.

      from enigma import (subsets, printf)
      
      # test: "A unless X (in which case B)"
      test = lambda X, A, B=True: (B if X else A)
      
      # available metals
      metals = (Cu, Ag, Au) = ("Cu", "Ag", "Au")
      
      # choose metals for the Blade, Hilt, Guard
      for (B, H, G) in subsets(metals, size=3, select="M"):
      
        # "the hilt shall be copper, unless the guard be silver in which
        # case the blade shall be copper unless the hilt is gold"
        if not test(G == Ag, H == Cu, test(H == Au, B == Cu)): continue
      
        # "the guard shall be copper unless the blade be gold in which
        # case the guard shall be silver unless the hilt is silver"
        if not test(B == Au, G == Cu, test(H == Ag, G == Ag)): continue
      
        # "the blade shall be gold unless the guard be gold in which case
        # the blade shall be silver unless the hilt is copper"
        if not test(G == Au, B == Au, test(H == Cu, B == Ag)): continue
      
        # output solution
        printf("B={B} H={H} G={G}")
      

      Solution: The blade is gold. The hilt is gold. The guard is silver.

      Like

      • John Crabtree's avatar

        John Crabtree 4:28 am on 27 October 2019 Permalink | Reply

        “unless” means that one condition or the other is true, but not both.
        Statements 2 and 3 give that the blade must be gold.
        Statement 2 simplifies to the the guard shall be silver unless the hilt is silver.
        The statements 1 and 2 give that the guard must be silver and the blade must be gold

        Like

        • John Crabtree's avatar

          John Crabtree 4:04 pm on 6 November 2019 Permalink | Reply

          An expanded and slightly corrected solution:

          “Unless” means one or the other, but not both.
          Putting statements 2 and 3 into Boolean form, where “.” means “AND”, “~” means “NOT”, and “+” means “OR”
          Statement 2. ~Bg.Gc + Bg.Gs.~Hs + Bg.~Gc.~Gs.Hs = 1
          Statement 3. Bg.~Gg + ~Bg.Bs.Gg.~Hc + ~Bg.~Bs.Gg.Hc = 1
          Multiplying the two and removing terms which are impossible gives
          Bg.Gs.~Hs = 1
          And so the blade is gold and the guard is silver.
          Statement 1. ~Gs.Hc + Gs.Bc.~Hc.~Hg + Gs.~Bc.Hg = Gs.~Bc.Hg = Hg = 1
          And so the hilt is gold.

          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