# remove one of the column in the output of Solve command

I would like to remove one variable in the output of the "Solve" command without changing the rest. For instance, in the following code

p = 6;
A = Solve[{p == x + y + z + t && x > 0 && y >= x && z >= y &&
t > 0}, {x, y, z, t}, Integers]


we have the output

{x -> 1, y -> 1, z -> 1, t -> 3},{x -> 1, y -> 1, z -> 2, t -> 2},{x -> 1, y -> 1, z -> 3, t -> 1},{x -> 1, y -> 2, z -> 2, t -> 1}


and I need to remove for example the last column for "t" and have:

{x -> 1, y -> 1, z -> 1},{x -> 1, y -> 1, z -> 2},{x -> 1, y -> 1, z -> 3},{x -> 1, y -> 2, z -> 2}


without changing the code in the input, I mean, I only want this change in the output section keeping the original output there.

• You can just do {x,y,z} /. A, no need to hack the solutions list. The reason why Solve returns lists of rules instead of lists of values is that you can use these rules to instantiate any expression you wish, not just a list of the solved variables in the original order. – Roman Aug 17 '19 at 13:27
• After you've set A=Solve[...]. Just try it out. – Roman Aug 17 '19 at 13:33
• Yes, you can do B=Most/@A. But it's a hack. – Roman Aug 17 '19 at 13:36
• I mean what I already referred to: whatever you will be doing with the list of solutions can be done without editing the solutions list. For example, if in the next step you want to find out what the value of $x^3$ is, then there is no need to first extract the first elements of A; rather, you can directly do x^3 /. A, because this replacement (/.) uses only those elements in A that are actually needed. Further, if you edit A then you need to make sure you get the right order of the elements, which is risky and causes errors when you guess it wrong. – Roman Aug 17 '19 at 13:43
• Although @Roman's answer is optimal, if you must remove solutions for t, you can use A /. (t -> _) :> Nothing – Bob Hanlon Aug 17 '19 at 19:55

Split the variables into {x, y, z}, {t} instead of {c, y, z, t}:
Solve[{p == x + y + z + t && x > 0 && y >= x && z >= y && t > 0}, {x, y, z}, {t}, Integers]