## Fultoa's Profile User Rating:

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
7 (0.02 per day)
Joined:
15-May 12
Profile Views:
121
Last Active:
Jun 05 2012 11:25 AM
Currently:
Offline

### Previous Fields

Dream Kudos:
0
Fultoa has not set their status

1. #### In Topic: Making Cryptarithm Solver - Improving It

Posted 24 May 2012

Hmm, I wrote this up, but never used the 'defs'. This doesn't work and only outputs the values of send, more and money.
```for s in range(1,10):
for e in range(0,10):
if s!=e:
for n in range(0,10):
if n not in [s,e]:
for d in range(0,10):
if d not in [s,e,n]:
print (s,e,n,d)
for m in range(1,10):
for o in range(0,10):
if m!=o:
for r in range(0,10):
if r not in [m,o]:
for e in range(0,10):
if e not in [m,o,r]:
print (m,o,r,e)
for m in range(1,10):
for o in range(0,10):
if m!=o:
for n in range(0,10):
if n not in [m,o]:
for e in range(0,10):
if e not in [m,o,n]:
for y in range(0,10):
if y not in [m,o,n,e]:
print (m,o,n,e,y)
send = s*1000 + e*100 + n*10 + d
more = m*1000 + o*100 + r*10 + e
money = m*10000 + o*1000 + n*100 + e*10 + y
if send + more == money:
print "  %1d%1d%1d%1d" % (s, e, n, d)
print " +%1d%1d%1d%1d" % (m, o, r, y)
print "-------"
print " %1d%1d%1d%1d%1d" % (m, o, n, e, y)

```
2. #### In Topic: Making Cryptarithm Solver - Improving It

Posted 22 May 2012

Hmm, I don't quite understand those yet, maybe I should go and learn them. Though, this...
```def process():
for s in range(1,10):
for e in range(0,10):
if s!=e:
for n in range(0,10):
if n not in [s,e]:
for d in range(0,10):
if d not in [s,e,n]:
def doSend(s,e,n,d)

def doSendMore(s,e,n,d,m,o,r):
print (m,o,r,e)

def doSend(s,e,n,d):
print (s,e,n,d)
for m in range(1,10):
for o in range(0,10):
if m!=o:
for r in range(0,10):
if r not in [m,o]:
doSendMore(s,e,n,d,m,o,r)

```

I believe I understand this a bit and can probably try and keep going. Would I need another def to figure out if 'send + more = money'?
3. #### In Topic: Making Cryptarithm Solver - Improving It

Posted 22 May 2012

Can't figure out how to edit posts, so I got this together.

```for s in range(1,10):
for e in range(0,10):
if s!=e:
for n in range(0,10):
if n not in [s,e]:
for d in range(0,10):
if d not in [s,e,n]:
print (s,e,n,d)
for m in range(1,10):
for o in range(0,10):
if m!=o:
for r in range(0,10):
if r not in [m,o]:
for e in range(0,10):
if e not in [m,o,r]:
print (m,o,r,e)
for m in range(1,10):
for o in range(0,10):
if m!=o:
for n in range(0,10):
if n not in [m,o]:
for e in range(0,10):
if e not in [m,o,n]:
for y in range(0,10):
if y not in [m,o,n,e]:
print (m,o,n,e,y)
word1 = s,e,n,d
word2 = m,o,r,e
word3 = m,o,n,e,y

if word1 + word2 == word3:
print word1
print word2
print word3

```

Currently I'm working on trying to get everything from declaring the word1, word2, etc. and down.
4. #### In Topic: Making Cryptarithm Solver - Improving It

Posted 22 May 2012

Sorry, it was my birthday this weekend and we went camping, anyways, may I ask what the "v" in your code means? Or is it something that I just didn't learn?

I was thinking of grabbing all the values using the first code you showed me above, and then checking using an if statement whether send + more = money.

```for m in range(1,10):
for o in range(0,10):
if m!=o:
for r in range(0,10):
if r not in [m,o]:
for e in range(0,10):
if e not in [m,o,r]:
print (m,o,r,e)

```
5. #### In Topic: Making Cryptarithm Solver - Improving It

Posted 16 May 2012

baavgai, on 16 May 2012 - 06:11 AM, said:

It looks like you're doing this:
```for s in range(1,10):
for e in range(0,10):
if e not in [s]:
for n in range(0,10):
if n not in [s,e]:
...

```

If so, then a one liner...
Spoiler

It's not a complete one liner, because at that point I get zero results. I was rather bummed. I looked over the logic.

Ultimately, I need this to be true: s*1000 + e*100 + n*10 + d + m*1000 + o*100 + r*10 + e = m*10000 + o*1000 + n*100 + e*10 + y

Which means, this must be true: s*1000 + e*91 + n*90 + d - m*9000 - o*900 - r*10 - y = 0

Just looking at that, if d!=y, then I don't think it can ever be true. Nor do I believe there is a set within the given range where it can be true, regardless of limits.

So, the shortest form of the given problem in python is pass.

Okay, I was just trying to follow what you showed me in your earlier post, where did I go wrong?

I guess you could solve for the first word at first using...
```for s in range(1,10):
if s!=e:
```

and keep using that for all the letters in 'SEND'. Or am I thinking the wrong way?

Member Title:
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

E-mail:
Private

### Friends

Fultoa hasn't added any friends yet.