We are given $4$ bags of coins such that (a) all coins in a given bag weigh the same, and (b) the coins of a given bag weigh either $1,2, $ or $3$ ounces. Take $1$ coin from bag $1,3$ coins from bag $2,9$ coins from bag $3$, and $27$ coins from bag $4$. Weighing these $40$ coins together on a scale yields a weight of $95$ ounces. Determine the weight of a coin from each of the $4$ bags.
I've been trying to solve the problem by setting up the equation $x+3y+9z+27w=95$ where $x,y,z,w \in (1,2,3) $ and trying up some values,but this is just taking me forever.
Is there some slicker way to do the problem ?