--
From: Python-list On
Behalf Of BlindAnagram
Sent: Saturday, December 15, 2018 7:41 AM
To: python-list@python.org
Subject: Re: Smarter algo, was Re: 03 digression by brute force
<<>>
There are quite a few Python based solvers for alphametics around on the net,
for example:
http://cod
ly a highly efficient built-in written in C, but it can
> >> totally be eliminated in this code as it is a constant. You can write
> >> {1,2,2,3,4,5,6,7,8,9} or [0,1] instead of calculating ranges.
> >>
> >> Naturally, this code does not scale up to finding the two solution
s a constant. You can write
>> {1,2,2,3,4,5,6,7,8,9} or [0,1] instead of calculating ranges.
>>
>> Naturally, this code does not scale up to finding the two solutions for:
>>
>> HAWAII + IDAHO +IOWA + OHIO = STATES
>>
>> The horizontal versions solved that easi
hen work on any
> number of columns by extracting columns backwards from the right and applying
> whatever logic, perhaps recursively. The possible carry amounts need to be
> estimated as no more than about the number of items being added minus one.
>
> But, I am ready to d
o I leave it as an exercise for the reader
-Original Message-
From: Python-list On
Behalf Of Peter Otten
Sent: Friday, December 14, 2018 3:21 AM
To: python-list@python.org
Subject: Smarter algo, was Re: 03 digression by brute force
jf...@ms4.hinet.net wrote:
> Just for fun:-)
jf...@ms4.hinet.net wrote:
> Just for fun:-) On my ooold PC, it takes 0.047 seconds to run the
> following algorithm on the problem 'SNED + MORE == MONEY".
> def tenThousand(u, Cin): # Cin == M
> global n
> if Cin == M:
> print(S, E, N, D, '+', M, O, R, E, '==', M, O, N, E, Y)
>