7
$\begingroup$

Consider the set S={w,x,y,z}. If the set of all possible sums of any three different elements from S is {-1,3,5,8}, then what is the set S?

How could I solve this function using Mathematica?

$\endgroup$

2 Answers 2

13
$\begingroup$
s = {w, x, y, z};
sum = {-1, 3, 5, 8};

add = Plus @@@ Subsets[s, {3}]
(* {w + x + y, w + x + z, w + y + z, x + y + z} *)

Solve[add == sum, s]
(* {{w -> -3, x -> 0, y -> 2, z -> 6}} *)
$\endgroup$
11
$\begingroup$
mat = ConstantArray[1, {4, 4}] - IdentityMatrix[4];
LinearSolve[mat, {-1, 3, 5, 8}]

{6, 2, 0, -3}

$\endgroup$
1
  • $\begingroup$ ... or, perhaps, Permutations@LinearSolve[mat, {-1, 3, 5, 8}]. $\endgroup$
    – kglr
    Apr 15, 2016 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.