Enigmatic Code

Programming Enigma Puzzles

Enigma 221: Moidores

From New Scientist #1367, 21st July 1983 [link]

I wonder if you could answer the following question from Hind’s Algebra, “designed for the use of students in the University”, published at Cambridge in 1839.

“In how many different ways may £100 be paid in crowns and moidores?”

Before answering you might ask —

A. Am I to include ways using only crowns or only moidores?

B. How many shillings is a moidore worth?

The answer to A, I can tell you, is “no”. The answer to the question is 14.

Now can you answer B? You will find you cannot be certain. But, assuming a moidore to be worth an exact number of shillings, what is the smallest and what is the greatest possible number of shillings in a moidore?

(Note to overseas and young readers: £1 = 4 crowns = 20 shillings).

Note: I am waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. The current estimate is that the line will be connected at the end of September 2014.



2 responses to “Enigma 221: Moidores

  1. Jim Randell 11 September 2014 at 10:28 am

    This Python program runs in 106ms.

    from enigma import irange, printf
    # generate total t from multiples of a and b
    # return (p, q) where: p.a + q.b = t, p > 0, q > 0
    def generate(t, a, b):
      for p in irange(1, t // a):
        (q, r) = divmod(t - p * a, b)
        if q > 0 and r == 0:
          yield (p, q)
    # consider the value of a moidore (in shillings)
    for m in irange(1, 1995):
      ss = list(generate(2000, 5, m))
      n = len(ss)
      if n == 14:
        printf("m={m} [n={n}]")

    Solution: The smallest possible value for a moidore is 27 shillings. The largest possible value is 140 shillings.

    The other possible values are 28 shillings and 135 shillings.

    The dictionary on my computer defines a moidore as:

    a Portuguese gold coin, current in England in the early 18th century and then worth about 27 shillings.

  2. Brian Gladman 11 September 2014 at 2:18 pm

    This is an example of a ‘frobenius problem’ (see http://ccgi.gladman.plus.com/wp/?page_id=563)

    from number_theory import frobenius_solve
    sol = []
    for moidore in range(1, 2000):
      t = tuple(frobenius_solve((5, moidore), 2000))
      ln = len(t) - (0 if t[0][1] else 1) - (0 if t[-1][0] else 1)  
      if ln == 14:
        sol += [moidore]
    print('Possible Moidore values: {0}'.format(tuple(sorted(sol))))

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: