Why Python don't accept 03 as a number?

Richard Damon Richard at Damon-Family.org
Sat Dec 8 17:29:56 EST 2018


On 12/8/18 12:40 PM, Avi Gross wrote:
> You are solving for: ab + aa + cd == ce

Actually, an even quicker analysis for this particular problem is:

from the 10s digits, a + a + c + carryin = c
Thus a and carryin must both be 0 (carryin can not be negative, nor any
of the variables)

thus the final solution space is:

b + d = e
a = 0
c any other digit (6 possible values for every combo of b, d, e)

if b is <= 4, there are 8-b possible values of d that will have a legal
value of e.
b = 1, we get d = 2, 3, 4, ... 7, 8
b = 2, we get d = 1, 3, 4, ... 6, 7 (8 would generate carry)
b = 3, we get d = 1, 2, 4, 5, 6
b = 4, we get d = 1, 2, 3, 5

if b >= 5 we get 9-b possible values of d (we no longer have to omit the
possible value of b  = d)

So the number of possible answers are:

(7+6+5+4+4+3+2+1)*6 = 192

(your 320 was you gave c 10 possible values, but you need to remove the
duplicates).



More information about the Python-list mailing list