This is an interview question. There are a total of 100 coins of values 5, 1, 0.2. I need to find a solution that satisfies the following constraints.
1) The total number of coins must be 100.
2) The total value of coins must be 100.
3) There must be at least 1 coin of each type.
So basically i need to solve these equations. x+y+z = 100 and 5x+1y+0.2z=100.
I've written a java program to brute force the values and found that 16 solutions exist.
1) 1, 94, 5
2) 2, 88, 10
3) 3, 82, 15
4) 4, 76, 20
5) 5, 70, 25
6) 6, 64, 30
7) 7, 58, 35
8) 8, 52, 40
9) 9, 46, 45
10) 10, 40, 50
11) 11, 34, 55
12) 12, 28, 60
13) 13, 22, 65
14) 14, 16, 70
15) 15, 10, 75
16) 16, 4, 80
How do i go about solving this manually?
Let $A$ be the number of $5's$, $B$ the number of $1's$, and $C$ the number of $.2's$. Clearly $C$ is divisible by $5$. Also we have $1≤C≤95$, which implies $5≤C≤95$.
Choose $C=5D$, for $1≤D≤19$. For a given $D$ we then seek to solve the pair of equations $$A+B=100-5D \quad \&\quad 5A+B=100-D$$
Subtracting the former from the latter we see that $$4A=4D\implies A=D$$.
Thus your triples are of the form $(D,100-6D,5D)$. Since we require $100-6D≥1$ we must have $99≥6D$ or $D≤16$ and we are done.