Enigmatic Code

Programming Enigma Puzzles

Tantalizer 414: Three men in a catastrophe

From New Scientist #964, 28th August 1975 [link]

George, Harris and I once decided to acquire a cat apiece. Dear little furry things they were, little bundles of innocence. Or so we thought before we got them home.

But original sin will out and we soon found that none of them was in the least well behaved. George’s was better behaved than the Siamese. The Persian was better behaved than Bubbles. Harris’s was better behaved than Fluff. The Tabby was not worse behaved than the Persian.

All in all we weren’t sorry when Montmorency, the dog, took a hand [paw?] and sent them caterwauling. He took a particularly satisfying bite out of Pollyanna. Whose cat was she?

[tantalizer414]

One response to “Tantalizer 414: Three men in a catastrophe

  1. Jim Randell 1 January 2020 at 8:36 am

    This Python program runs in 82ms.

    Run: [ @repl.it ]

    from enigma import subsets, printf
    
    # behaviour scores
    scores = list(subsets((0, 1, 2), size=len, select="P"))
    
    # assign scores by breed
    for (S, P, T) in scores:
    
      # "the Tabby is better than Persian"
      if not(T > P): continue
    
      # assign scores by owner
      for (G, H, I) in scores:
    
        # "George's is better than the Siamese"
        if not(G > S): continue
    
        # assign scores by cat name (X = Pollyanna)
        for (B, F, X) in scores:
    
          # "Harris's is better than Fluff"
          if not(H > F): continue
    
          # "the Persian is better than Bubbles"
          if not(P > B): continue
    
          # map behaviour to owners
          m = dict(zip((G, H, I), "GHI"))
          # answer is the owner of X
          printf("owner = {r} [breed: S={S} P={P} T={T}; owner: G={G} H={H} I={I}; name: B={B} F={F} X={X}]", r=m[X])
    

    Solution: Harris was Pollyanna’s owner.

    The cats are:

    best = Pollyanna, Tabby, owned by Harris
    middle = Fluff, Persian owned by George
    worst = Bubbles, Siamese owned by I

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: