Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2014-12-11 19:59:37

Faria
Member
Registered: 2014-12-11
Posts: 8

Algebra puzzle

ABC + DEF = GHIJ
solution is given : 437 + 589 = 1026
or
743 + 859 = 1602
how is this possible ??

Offline

#2 2014-12-11 22:16:21

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

Hi;

Alphametics can have more than 1 solution. This one has 96 solutions!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2014-12-11 22:36:33

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

Hi;
How do you know it have 96 solutions? Through M? Explain please.


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#4 2014-12-11 22:44:46

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

The fastest way to get an answer to this type problem especially if there are multiple solutions is to use M.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#5 2014-12-11 22:45:26

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

How do you do that with m?


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#6 2014-12-11 22:57:21

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

Do you program yet?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#7 2014-12-11 22:58:16

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

No. But I want to


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#8 2014-12-11 23:02:59

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

You have two options to code this:

1) Download someone elses code.

2) Write it yourself.

For 1) I recommend Rashers' code.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#9 2014-12-11 23:03:36

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

Do you do Java?


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#10 2014-12-11 23:06:02

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

I came from BASIC -> Assembly -> C++ -> M. No room for Java in there.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#11 2014-12-11 23:06:37

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

Maybe we could learn Java together? I really like Java.


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#12 2014-12-11 23:08:57

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

Nope, I hate it. Do not let that stop you though if you really like it you should do it.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#13 2014-12-11 23:09:45

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

Why do you hate it?


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#14 2014-12-11 23:13:15

David
Member
From: Bumpkinland
Registered: 2014-04-23
Posts: 3,164

Re: Algebra puzzle

Perhaps we could write the program together for m?


His dominion is an everlasting dominion, Which shall not pass away, And His kingdom the one Which shall not be destroyed.

Offline

#15 2014-12-11 23:14:41

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

I have it written already, how do you think I got the answers?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#16 2014-12-12 21:34:56

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Algebra puzzle

Hi Bobby,

I also got 96 answers, but am having trouble getting M to restrict the output to just those 96. My output includes invalid answers with a leading zero.

Could you please point me in the right direction?

Thanks.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#17 2014-12-12 21:37:18

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

Sometimes I roll my own or sometimes I just use Rasher's. Want to see his?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#18 2014-12-12 21:42:43

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Algebra puzzle

Yes please. You probably saw my comment in the other thread about me going fishing blindly without success...


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#19 2014-12-12 21:49:33

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

ClearAll[a, b, c, d, e, f, g, h, i, j];

(*Define alphabet,terms,and sum*)

vars = {a, b, c, d, e, f, g, h, i, j};
term1 = {a, b, c};
term2 = {d, e, f};
sum = {g, h, i, j};

(*Define Constraints*)
(*minimum and maximun values*)
{min, max} = {0,
    9};

(*must all letters assume differing values?*)
mustDiffer = True;

(*Additional constraints,use {} for none*)

conditions = {a > 0, d > 0, g > 0};

(*Solve It*)

solutions = 
  TableForm[
   Select[vars /. 
     Solve[Join[{FromDigits[term1] + FromDigits[term2] == 
         FromDigits[sum]}, Table[min <= zz <= max, {zz, vars}], 
       conditions], vars, Integers], ! mustDiffer || Unequal @@ # &], 
   TableHeadings -> {None, vars}];

(*Display Results& Checks*)
If[
 solutions[[1]] == vars || 
  solutions[[1]] == {}, "No solutions found for given", 
 Labeled[solutions, {Length[
      solutions[[1]]] "Solutions found for given\n", 
    "\nCheck all ok:" (varSave = SymbolName /@ vars;
      res = 
       And @@ ((ToExpression[
             ToString[varSave] <> "=" <> ToString[#]];
            
            FromDigits[term1] + FromDigits[term2] == 
             FromDigits[sum]) & /@ solutions[[1]]);
      ClearAll @@ varSave; res)}, {Top, Bottom}] // Framed]

This is Rasher's code.

It is not that fast but it is generic.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#20 2014-12-12 21:54:05

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Algebra puzzle

Thanks! I've saved it in my M, and am looking at it now...


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#21 2014-12-12 22:00:01

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

It should be easy to adapt it to any of that type.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#22 2014-12-12 22:17:50

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Algebra puzzle

It works instantaneously with SEND + MORE = MONEY.

ABC + DEF = GHIJ takes about 18 seconds for a complete solution that excludes answers with leading zeros, whereas my code takes about 22 seconds for answers that don't exclude them.

I haven't tried the code from hummmer98's thread yet (hope I can get the 2-equation thing going).


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#23 2014-12-12 22:18:23

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

hummer98?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#24 2014-12-12 22:29:23

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Algebra puzzle

hummmer98's thread ("help me please and fast")

Btw, hummmer98 hasn't come back on board yet, so maybe you were too slow with your answer! wink


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#25 2014-12-12 22:37:18

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Algebra puzzle

Yes, he wanted super speed m and got me instead.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB