Solution to Problem 93



Congratulations to this week's winner, chosen at random from all correct solutions,

Deyo Dada

Other correct solutions were sent in by David Aberle, Nick Jaegle, Joe Powers, Carl Westine, Andrew Hess, David Perkins, Ray Kremer.  Further correct solutions were submitted by Brian Laughlin, Burkhart Venzke, Melissa West, Aaron David Kahn, Al Zimmermann, Shekhar Joglekar, Ken Buch, Denis Borris, Philippe Fondanaiche, Ariel Flat.


Let's write the subtraction problem as follows:

    b    c    d    e 
-   e    d    c    b    a 
  x    y    m    n    p
where the letters denote the digits of the numbers.  Since the first number is the larger of the two, either a > e, or a = e and b > d. It's clear that m must be either 0 or 9 depending on whether you have to borrow or not.  The following table describes the different possibilities.
 
  x y m n p
a > e, b > d a - e b - d - 1 9 9 + d - b 10 + e - a
a > e, b = d a - e - 1 9 9 9 10 + e - a
a > e, b < d a - e - 1 10 + b - d 0 d - b - 1 10 + e - a
a = e, b > d 0 b - d - 1 9 10 + b - d 0

These can all be summarized by the rules

x = 10 - p   and    y = 8 - n

except when
(1)  p = 0, in which case x = 0, and y = 9 - n;
(2)  m = 0, in which case x = 9 - p, and y = 9 - n;
(3)  m = n = 9, p ¹ 0, in which case x = 9 - p, and y = 9.

Al Zimmerman proposes the following three step algorithm:
Step 1. Cast out 99's. Do this by repeatedly adding the the first digit of the result to the last two until you reach a two digit number less than 99.
Step 2. Subtract each digit from 99.
Step 3. Reverse the digits. For example, if the result of the subtraction were 994, you proceed as follows:

Step 1. 994 -> 103 -> 04; Step 2. 04 -> 95; Step 3. 95 -> 59
These are the required two digits.

You are visitor number  3985 to this page.
Page last updated 12 October 2000.