Enigmatic Code

Programming Enigma Puzzles

Enigma 1352: Old MacDonald

From New Scientist #2511, 6th August 2005

Older puzzlers know that 14 pounds make a stone and 8 stone make a hundredweight. Old MacDonald sold four varieties of potato, Primes, Queens, Roosters and Superb in 1-stone bags. One kind of bag, Chippers, contained an integral number of pounds of each variety, in order of increasing weight from Primes to Superbs; the other, Boilers, contained an integral number of pounds of each variety in order of increasing weight from Suberb to Primes. The number of pounds of each variety in each bag were different.

He also sold 1-hundredweight sacks of Commercial, which consisted of bags of Boilers and Chippers mixed. It so happened that in Commercial, half the weight of Superb came from Boiler bags and half from Chippers, and the number of pounds of Queens equalled the number of pounds of Roosters.

How many pounds of Primes were in 1 hundredweight of Commercial?

[enigma1352]

One response to “Enigma 1352: Old MacDonald

  1. Jim Randell 28 January 2014 at 9:01 am

    This Python program runs in 34ms

    from enigma import irange, printf
    
    # split 14 into increasing 4-tuples (a, b, c, d)
    s14 = list()
    for a in irange(0, 14):
      for b in irange(a + 1, 14):
        for c in irange(b + 1, 14):
          d = 14 - (a + b + c)
          if c < d:
            s14.append((a, b, c, d))
    
    # choose a split for chippers
    for (p1, q1, r1, s1) in s14:
      # and a split for boilers
      for (s2, r2, q2, p2) in s14:
        # and choose a split for commercial
        for n1 in irange(0, 8):
          n2 = 8 - n1
    
          # check the conditions
          if not(s1 * n1 == s2 * n2): continue
          if not(n1 * q1 + n2 * q2 == n1 * r1 + n2 * r2): continue
    
          printf("C = {p1}P + {q1}Q + {r1}R + {s1}S")
          printf("B = {p2}P + {q2}Q + {r2}R + {s2}S")
          printf("Commercial = {n1}C + {n2}B")
    
          # solution
          p = n1 * p1 + n2 * p2
          printf("{p}P in Commercial")
    

    Solution: There are 32 pounds of Primes in 1 hundredweight of Commercial.

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: