Enigmatic Code

Programming Enigma Puzzles

Tantalizer 473: Pigeon post

From New Scientist #1024, 28th October 1976 [link]

In the name of democracy the officers of our Pigeon Fanciers Club announce that they would not stand for re-election this year. This cheered the rest of us no end, until we found that it applied only individually. Collectively they planned to retain all five offices for the umpteenth year running.

To allay suspicions, the plot was a mite complex. There would be no direct swaps. Bumble would take the post of the man who was to become Organiser. Crumble would take the post of the man who was to become Treasurer. Dimwit would take the post of the man who would take Amble’s post. The current Vice-President would take the post vacated by the new President. Eggfrith would become Secretary, despite his wish to become the Organiser.

It all worked flawlessly, of course.

Who was and is what?

[tantalizer473]

Advertisements

One response to “Tantalizer 473: Pigeon post

  1. Jim Randell 13 September 2017 at 9:34 am

    This Python program looks at all possibilities for both assignments of posts. It runs in 68ms.

    from itertools import permutations
    from enigma import join, printf
    
    # labels for the posts
    jobs = "OPSTV"
    
    # indices for the people
    (A, B, C, D, E) = (0, 1, 2, 3, 4)
    
    # consider initial jobs
    for p1 in permutations(jobs):
    
      # "E wishes to become O", so he isn't O to start with
      if p1[E] == 'O': continue
    
      # and the final jobs
      for p2 in permutations(jobs):
    
        # "E becomes S"
        if p2[E] != 'S': continue
    
        # no-one keeps the same job
        if any(x == y for (x, y) in zip(p1, p2)): continue
    
        # no-one swaps jobs
        if any(p2[p1.index(j)] == p1[p2.index(j)] for j in jobs): continue
    
        # "B takes the post of the man who becomes O"
        if not(p2[B] == p1[p2.index('O')]): continue
    
        # "C takes the post of the man who becomes T"
        if not(p2[C] == p1[p2.index('T')]): continue
    
        # "D takes the post of the man who takes A's post"
        if not(p2[D] == p1[p2.index(p1[A])]): continue
    
        # "The current V takes the post vacated by the new P"
        if not(p2[p1.index('V')] == p1[p2.index('P')]): continue
    
        printf("before = ({p1}), after = ({p2})", p1=join(p1, sep=", "), p2=join(p2, sep=", "))
    

    Solution: Before: Amble was President, Bumble was Secretary, Crumble was Organiser, Dimwit was Vice-President, Eggfrith was Treasurer. After: Amble is Treasurer, Bumble is Vice-President, Crumble is President, Dimwit is Organiser, Eggfrith is Secretary.

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: