Enigmatic Code

Programming Enigma Puzzles

Enigma 1716: Pyramid selling

From New Scientist #2883, 22nd September 2012 [link]

I commissioned a goldsmith to make some identical solid gold tetrahedrons, in which the original specification gave the length of each of the sides. He calculated what the cost of the gold would be and, as I could afford a certain whole number percentage more, I asked him to increase their size by that percentage. He started making the tetrahedrons, but made the error of increasing each side by that percentage. After he had made one he realised that if he continued in this way he would use much more gold than expected. So he made the second tetrahedron with each side reduced by that same percentage from its original specification. The rest he made to the original specification.

I still got the required number of tetrahedrons and in fact the overall effect was to increase the amount of gold used by the percentage I wanted.

How many tetrahedrons did I order, and what percentage increase did I ask for?



One response to “Enigma 1716: Pyramid selling

  1. Jim Randell 19 September 2012 at 9:46 pm

    I think a little bit of algebra gives the solution quite easily without programming. But here’s a program that verifies the solution.

    from fractions import Fraction
    from enigma import irange, printf
    # if k is the cost of one original tetrahedron
    # (or, in fact, any solid object)
    # and n is the number of tetrahedra required
    # so I order n tetrahedra at a cost of kn
    # if p is the whole percentage increase I can afford
    # let f be the fractional increase: f = p / 100
    # it turns out I can afford to spend k(1 + f)n
    # the maker makes one at a cost of: k(1+f)^3
    # one at a cost of: k(1-f)^3
    # and n-2 at the original cost
    # hence: k(1+f)n = k(1+f)^3 + k(1-f)^3 + k(n-2)
    # cancel k, and solve for n:
    # n + fn = (1+f)^3 + (1-f)^3 + n - 2
    # n = ((1+f)^3 + (1-f)^3 - 2) / f
    # (I won't expand the cubics to keep some sense of mystery)
    # and n is an integer > 2
    for p in irange(1, 99):
      f = Fraction(p, 100)
      n = (pow(1 + f, 3) + pow(1 - f, 3) - 2) / f
      if not(n.denominator == 1 and n.numerator > 2): continue
      printf("n={n} p={p}%")

    Solution: You ordered 3 tetrahedra, and asked for an increase in size of 50%.

    Expanding the cubic equations and cancelling common terms leads to the equation: f = n / 6, where n is a positive integer greater than 2 and f can be expressed as a whole number percentage. This quickly leads to the solution: n = 3, f = 50%.

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: