Enigmatic Code

Programming Enigma Puzzles

Tantalizer 486: Go to work on an egg

From New Scientist #1037, 3rd February 1977 [link]

Miss Megawatt is one of those sensible people who go to work on an egg. Since variety is the spice of life, she cooks it differently each day but, seeing virtue in routine too, she repeats the same order each working week. She eats no eggs at weekends.

Here are five statements she made recently to a chap from Consumer Research. To keep him on his toes, she included a false one.

1. “On Wednesdays I have it poached or boiled.”
2. “When yesterday’s was coddled, tomorrow’s will be scrambled or vice versa.”
3. “Poached is neither next before nor next after scrambled.”
4. “I coddle and poach earlier in the week than I boil or scramble.”
5. “I scramble earlier than I fry and later than I poach.”

What is her order each working week?

[tantalizer486]

Advertisements

One response to “Tantalizer 486: Go to work on an egg

  1. Jim Randell 29 March 2017 at 2:14 pm

    Programatically we can assign a day of the week to each cooking style, and then look for an assignment that makes exactly four of the statements true.

    This Python program runs in 38ms.

    from itertools import permutations
    from enigma import irange, join, printf
    
    # number the days of the week from 1 to 5
    days = (Mo, Tu, We, Th, Fr) = irange(1, 5)
    
    # consider the order of B(oiled), C(oddled), F(ried), P(oached), S(crambled)
    for (B, C, F, P, S) in permutations(days):
    
      # evaluate the statements:
      ss = (
        # 1. "On Wednesdays I have it poached or boiled"
        (We == B or We == P),
    
        # 2. "When yesterday's was coddled, tomorrow's will be scrambled or vice versa"
        # so we can have: "... C ? S ..." or "... S ? C ..."
        (abs(C - S) == 2),
    
        # 3. "Poached is neither next before nor next after scrambled"
        # so we can't have "... P S ..." nor "... S P ..."
        (abs(S - P) != 1),
    
        # 4. "I coddle and poach earlier in the week then I boil or scramble
        (max(C, P) < min(B, S)),
    
        # 5. "I scramble earlier than I fry and later than I poach"
        (P < S < F),
      )
    
      if ss.count(True) == 4:
        # output the cooking methods in order
        order = tuple(t[1] for t in sorted(zip((B, C, F, P, S), 'BCFPS')))
        printf("{order} {ss}", order=join(order, sep=", "))
    

    Solution: Monday = Coddled; Tuesday = Poached; Wednesday = Boiled; Thursday = Scrambled; Friday = Fried.

    Statement 2 is the false one.

    Appropriately the fried egg is prepared on Friday.

    There is an order in which all the statements are true:

    Monday = Poached;
    Tuesday = Coddled;
    Wednesday = Boiled;
    Thursday = Scrambled;
    Friday = Fried.

    Poached and Coddled are interchanged. And this is presumably what Consumer Research will conclude (unless she also told them that one of the statements was false).

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: