Enigmatic Code

Programming Enigma Puzzles

Tantalizer 426: Drawing conclusions

From New Scientist #977, 27th November 1975 [link]

Those aspiring architects Matthew, Mark, Luke and John were discussing the design test they had taken the week before. The results were not yet public, but there had, of course, been leaks.

Matthew summed the position up: “We all know that there were seven candidates, exactly four of whom passed. None of us here knows how any of the absent candidates fared. None of us yet knows whether he himself passed or failed. Each of us here knows the result of each of the other three present”.

“That is interesting”, said Mark, “and your final sentence is news to me. But I still do not know whether I passed”.

“Matthew’s final sentence was news to me too”, Luke said presently, “but even now I too cannot work out whether I passed”.

On being told that they are bright lads and have deduced all they can, you can discover one result. Whose and what?

[tantalizer426]

One response to “Tantalizer 426: Drawing conclusions

  1. Jim Randell 26 June 2019 at 7:45 am

    I wasn’t sure how Mark and Luke would not know if they knew the results of the other three or not, so I treated their statements as: “Even if I knew the results of the other three, I could still not deduce my own result”.

    This Python program runs in 96ms.

    Run: [ @repl.it ]

    from enigma import subsets, filter_unique, printf
    
    # labels
    names = (Matt, Mark, Luke, John) = (0, 1, 2, 3)
    
    # between them they have 1, 2, 3, 4 passes
    ss = list(s for s in subsets('PF', size=4, select='M') if s.count('P') > 0)
    
    # Matthew knows how the other 3 have done, but can't deduce his own result
    (_, ss) = filter_unique(ss, (lambda s: (s[Mark], s[Luke], s[John])), (lambda s: s[Matt]))
    
    # if Mark knew the other 3's results he couldn't deduce his own result
    (_, ss) = filter_unique(ss, (lambda s: (s[Matt], s[Luke], s[John])), (lambda s: s[Mark]))
    
    # if Luke knew the other 3's results he couldn't deduce his own result
    (_, ss) = filter_unique(ss, (lambda s: (s[Matt], s[Mark], s[John])), (lambda s: s[Luke]))
    
    # are any of them uniquely identified?
    for k in names:
      rs = set(s[k] for s in ss)
      if len(rs) == 1:
        name = [ "Matthew", "Mark", "Luke", "John" ][k]
        printf("{name} = {r}", r=rs.pop())
    

    Solution: We can deduce that John has passed.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: