Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5353
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Solve - takes very long time |
| Date | 2011-10-04 05:33 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6e5rl$kbf$1@smc.vnet.net> (permalink) |
| References | <j6bris$8m4$1@smc.vnet.net> |
"Fredob" <fredrik.doberl@gmail.com> schrieb im Newsbeitrag
news:j6bris$8m4$1@smc.vnet.net...
> Hi,
>
> I tried the following on Mathematica 8 and it doesn't seem to stop
> running (waited 40 minutes on a 2.6 Ghz processor w 6 GB of primary
> memory).
>
> Solve[
> {100*Subscript[x, 2] + 10*Subscript[x, 1] + Subscript[x, 0] +
> 100*Subscript[y, 2] + 10*Subscript[y, 1] + Subscript[y, 0] ==
> 100*Subscript[z, 2] + 10*Subscript[z, 1] + Subscript[z, 0],
> Subscript[x, 0] > 0, Subscript[y, 0] > 0, Subscript[z, 0] > 0,
> Subscript[x, 1] > 0, Subscript[y, 1] > 0, Subscript[z, 1] > 0,
> Subscript[x, 2] > 0, Subscript[y, 2] > 0, Subscript[z, 2] > 0,
> Subscript[x, 0] <= 9, Subscript[y, 0] <= 9, Subscript[z, 0] <= 9,
> Subscript[x, 1] <= 9, Subscript[y, 1] <= 9, Subscript[z, 1] <= 9,
> Subscript[x, 2] <= 9, Subscript[y, 2] <= 9, Subscript[z, 2] <= 9,
> Subscript[x, 0] != Subscript[y, 0] != Subscript[z, 0] != Subscript[
> x, 1] != Subscript[y, 1] != Subscript[z, 1] != Subscript[x, 2] !=
> Subscript[y, 2] != Subscript[z, 2]},
> {Subscript[x, 2], Subscript[y, 2], Subscript[z, 2], Subscript[x, 1],
> Subscript[y, 1], Subscript[z, 1], Subscript[x, 0], Subscript[y, 0],
> Subscript[z, 0] },
> Integers]
>
> The problem was a homework for my daugther where you are supposed to
> use all digits to build - but only once - 2 three digit numbers and
> addition.
>
>
Even the simplest operation of the type Reduce[eq, x>0] takes very long
time also on my PC.
It might be better to look for a different approach to the problem.
I understand you are looking for three numbers
A={a,b,c},B={d,e,f},C={g,h,i} such that
(1) A+B = C and
(2) {a,b, ...,i} = Permutation {1,2, ...,9}
There are 168 different solutions (i.e. with A<B),
These are the 4 with the smallest C (=459)
{186, 273, 459}, {183, 276, 459}, {176, 283, 459}, {173, 286, 459}
these are the 8 with the largest C (=981)
{357, 624, 981}, {354, 627, 981}, {327, 654, 981}, {324, 657, 981},
{246, 735, 981}, {245, 736, 981}, {236, 745, 981}, {235, 746, 981}
The code I used for finding all solutions is
p=FromDigits/@(Partition[#, 3] & /@ Permutations[Range[9]]); (* form
all possible sets of three 3-digit numbers *)
sp = Select[p, #[[1]] + #[[2]] == #[[3]] &]; (* the equation *)
sp1 = Select[sp, #[[1]] < #[[2]] &]; (* no repetition *)
Reverse /@ Sort[Reverse /@ sp1] (* sort according to sum *)
Wolfgang
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Solve - takes very long time Fredob <fredrik.doberl@gmail.com> - 2011-10-03 08:26 +0000 Re: Solve - takes very long time Ray Koopman <koopman@sfu.ca> - 2011-10-04 05:33 +0000 Re: Solve - takes very long time "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-04 05:33 +0000 Re: Solve - takes very long time Peter Pein <petsie@dordos.net> - 2011-10-04 05:36 +0000 Re: Solve - takes very long time DrMajorBob <btreat1@austin.rr.com> - 2011-10-05 08:06 +0000
csiph-web