On 14/12/2018 02:24, 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".
>
> -
> import time
> import itertools
>
> #S, E, N, D, M, O, R, Y
> n = 0
> digits = {x fo
--Original Message-
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,
is is much faster.
> >>
> >> Range() is probably 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.
> >>
> >>
, 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 solutions for:
>>
>> HAWAII + IDAHO +IOWA + OHIO = S
> all entries in it as characters, right justified. You can then 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
s being added minus one.
But, I am ready to do other things so 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 b
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)
>
Just for fun:-) On my ooold PC, it takes 0.047 seconds to run the following
algorithm on the problem 'SNED + MORE == MONEY".
-
import time
import itertools
#S, E, N, D, M, O, R, Y
n = 0
digits = {x for x in range(10)}
def tenThousand(u, Cin): # Cin == M
global n
"Avi Gross" writes:
> SYNOPSIS: One way to solve math puzzle by brute force. (message sent earlier
> disappeared)
>
>
>
> Quick note. Jack started by asking why python does not like decimal
> numbers with leading zeroes. When asked to explain, he said he was
> trying to solve word problems usi
On 2018-12-12 02:06, Avi Gross wrote:
[snip]
My main point though is that a leading zero can appear including in bank
account numbers, social security numbers and so on. But I accept that
historically python is as it is. As I mentioned, some functions like int() can
deal with them.
Bank accou
SYNOPSIS: One way to solve math puzzle by brute force. (message sent earlier
disappeared)
Quick note. Jack started by asking why python does not like decimal numbers
with leading zeroes. When asked to explain, he said he was trying to solve word
problems using python. Someone mentioned probl
11 matches
Mail list logo