Enigmatic Code

Programming Enigma Puzzles

Enigma 281: Family planning

From New Scientist #1428, 1st November 1984 [link]

Dick and Fecunda are family planning counsellors; so a bit of showing off is excusable. At any rate, the oldest of their five kids is called “Monday”, having been born on a Monday, the second is “Tuesday” (born on Tuesday), the third “Wednesday” (born on Wednesday), and so on. That makes the order of age clear enough but leaves the sexes more enigmatic.

Monday claims to be of different sex to Friday. Tuesday claims to have exactly three sisters; Friday claims to have exactly three brothers. Wednesday claims to have just one older sister and just one younger sister. Thursday claims to have a younger brother.

In fact there is at least one child of each sex. Any claims by one sex are true, whereas any by the other are false.

Can you list the sexes in the right order, starting with Monday?

[enigma281]

Advertisements

One response to “Enigma 281: Family planning

  1. Jim Randell 17 May 2015 at 7:47 am

    This Python program examines all the possibilities in 34ms.

    from itertools import product
    from enigma import printf
    
    # one gender always tells the truth
    def true(*s):
      return all(s)
    
    # one gender always lies
    def false(*s):
      return not any(s)
    
    # assign a gender to each child
    for s in product('MF', repeat=5):
      # each gender is represented
      if not('M' in s and 'F' in s): continue
    
      (Mon, Tue, Wed, Thu, Fri) = s
    
      # assign truth functions to each gender
      for (M, F) in ((true, false), (false, true)):
        fn = { 'M': M, 'F': F }
    
        # 1. "Monday claims to be a different sex to Friday"
        if not fn[Mon](Mon != Fri): continue
    
        # 2. "Tuesday claims to have exactly three sisters"
        if not fn[Tue]((Mon, Wed, Thu, Fri).count('F') == 3): continue
    
        # 3. "Friday claims to have exactly three brothers"
        if not fn[Fri]((Mon, Tue, Wed, Thu).count('M') == 3): continue
    
        # 4. "Wednesday claims to have just one older sister and just one younger sister"
        if not fn[Wed]((Mon, Tue).count('F') == 1, (Thu, Fri).count('F') == 1): continue
    
        # 5. "Thursday claims to have a younger brother"
        if not fn[Thu](Fri == 'M'): continue
    
        printf("Mon={Mon} Tue={Tue} Wed={Wed} Thu={Thu} Fri={Fri} [M={M} F={F}]", M=M.__name__, F=F.__name__)
    

    Solution: Monday and Tuesday are male. Wednesday, Thursday and Friday are female.

    The boys always tell the truth, and the girls always lie.

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: