RE: Smarter algo, was Re: 03 digression by brute force

2018-12-16 Thread Avi Gross
-- 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

Re: Smarter algo, was Re: 03 digression by brute force

2018-12-16 Thread jfong
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

Re: Smarter algo, was Re: 03 digression by brute force

2018-12-15 Thread BlindAnagram
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

Re: Smarter algo, was Re: 03 digression by brute force

2018-12-15 Thread jfong
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

RE: Smarter algo, was Re: 03 digression by brute force

2018-12-14 Thread Avi Gross
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:-)

Smarter algo, was Re: 03 digression by brute force

2018-12-14 Thread Peter Otten
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) >