Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5357 > unrolled thread

Re: Solve - takes very long time

Started byHeike Gramberg <heike.gramberg@gmail.com>
First post2011-10-04 05:35 +0000
Last post2011-10-04 05:35 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Solve - takes very long time Heike Gramberg <heike.gramberg@gmail.com> - 2011-10-04 05:35 +0000

#5357 — Re: Solve - takes very long time

FromHeike Gramberg <heike.gramberg@gmail.com>
Date2011-10-04 05:35 +0000
SubjectRe: Solve - takes very long time
Message-ID<j6e5vf$kcc$1@smc.vnet.net>
It's a bit of a brute force approach, but as an alternative you could  
do something like this to find all the combinations

Needs["Combinatorica`"]
allsets = Map[{100, 10, 1}.# &, Partition[#, 3] & /@ Permutations[9], {2}];
triples = Cases[allsets, a_ /; (a[[1]] < a[[2]] && a[[1]] + a[[2]] == a[[3]])]

This basically works by generating all triples of 3-digit numbers {a, b, c}
such that the triple contains each digit from 1 to 9 exactly once and then
choosing the ones such that a+b==c.

Heike.

On 3 Oct 2011, at 10:21, Fredob wrote:

> 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.
>
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web