Enigmatic Code

Programming Enigma Puzzles

Enigma 1726: Conspicuous consumption

From New Scientist #2893, 1st December 2012 [link]

My uncle came to visit me by car on three days last week, taking the same round route each time, but returning by a different road from the one used to come to my hilltop home. On his arrival at my home on the first day, the miles per gallon (mpg) reading on his car’s display was 36.0, on the second 42.5 and on the third 44.0, when it also gave a reading of 71.5 for the cumulative mileage.

He told me that he had zeroed the display before he set out on day one, and had made no other journeys. He also says that, if I assume the mpg for the common approach and common return journeys are consistent from day to day, and that all the numerical values are exact, I should get a whole number answer for the mpg for the journey from my house back to his.

What is this whole number?



2 responses to “Enigma 1726: Conspicuous consumption

  1. Jim Randell 28 November 2012 at 6:09 pm

    The problem boils down to a set of 4 equations in 4 variables. This program uses SymPy to solve them (although you can do it on the back of an envelope if you prefer – or use Wolfram Alpha). It runs in 288ms.

    from sympy import symbols, Eq, Rational, solve
    from enigma import printf
    # symbols for distances and fuel consumption
    (d1, d2, g1, g2) = symbols('d1,d2,g1,g2')
    # equations
    eqs = [
      # day 1
      Eq(d1 / g1, 36),
      # day 2
      Eq((2 * d1 + d2) / (2 * g1 + g2), Rational(85, 2)),
      # day 3
      Eq((3 * d1 + 2 * d2) / (3 * g1 + 2 * g2), 44),
      # cumulative distance
      Eq(3 * d1 + 2 * d2, Rational(143, 2)),
    r = solve(eqs)
    (rd1, rd2, rg1, rg2) = (r[d1], r[d2], r[g1], r[g2])
    printf("d2/g2={a} [d1={rd1} d2={rd2} g1={rg1} g2={rg2}]", a=rd2 / rg2)

    Solution: The fuel consumption for the return journey is 62 mpg.

    • Jim Randell 5 January 2013 at 5:00 pm

      Here’s the back of the envelope method:

      From day 1 we deduce:

      d1 = 36g1

      From day 2:

      (2d1 + d2) / (2g1 + g2) = 85/2

      which we can rewrite as:

      4d1 + 2d2 = 170g1 + 85g2

      From day 3:

      (3d1 + 2d2) / (3g1 + 2g2) = 44

      which we rewrite as:

      3d1 + 2d2 = 132g1 + 88g2

      subtracting these two we get:

      d1 = 38g1 – 3g2

      and substituting for d1:

      36g1 = 38g1 – 3g2

      which simplifies to:

      2g1 = 3g2

      So, rewriting things in terms of g2 we get, from day 1:

      d1 = 36g1 = 54g2

      and from day 2:

      216g2 + 2d2 = 255g2 + 85g2

      which simplifies to:

      2d2 = 124g2

      And the solution we are looking for (fuel consumption on the return journey) is given by:

      d2 / g2 = 62

      We can then go further and determine that values for all the variables using the additional information we are given, which is the cumulative distance:

      3d1 + 2d2 = 143/2

      rewriting in terms of g2, we get:

      162g2 + 124g2 = 143/2

      which simplifies to give us a value for g2:

      gallons used on the return journey, g2 = 143/572 = ¼

      and then the other values follow:

      distance of the return journey in miles, d2 = 62g2 = 15½

      gallons used on the outward journey, g1 = ⅜

      distance of the outward journey in miles, d1 = 54g2 = 13½

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: