Why Python don't accept 03 as a number?
Avi Gross
avigross at verizon.net
Sat Dec 8 18:23:36 EST 2018
[DISCLAIMER: less about python than analysis of a puzzle]
Richard,
Thank you for pointing out that c in the puzzle is constrained. That
explains why my 320 answers are too many. It cannot be 0 as "a" is always
zero and it cannot be the three other values that b,d,e are using at the
time. So my earlier solution should say c is any of six available choices.
So 6 * 32 is 192 solutions.
Your analysis requires considering a carry from the right column into the
left. I skipped that by converting something like ab to 10*a+b.
This all began with someone trying to enter 03 which suggests they may have
been starting to look at it your way. As a logic puzzle to do those with
pencil and paper, your analysis is spot on. There is additional info to be
gleaned by looking at adding columns. I chose a perspective on more brute
force methods and whittled it down to less forceful. Given that c was
removed from the equation, though, and that only 6 of 10 options are
available for any given time, I would need another pass at the answers and
for each solution for the others (b,d,e if we agree a is always 0) I would
need to make six entries with c set successively to digits-set(0,b,d,e} or
something like that.
I note that programming some of the kinds of analysis some of these puzzles
use is not as easy in programming languages as a more brute-force approach
that computers are better at than humans.
-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Richard Damon
Sent: Saturday, December 8, 2018 5:30 PM
To: python-list at python.org
Subject: Re: Why Python don't accept 03 as a number?
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).
--
https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list