Answer:
14 are red
Explanation:
Let's identify the 2 types of transactions Juan machines do:
w : changes 1 white token into 4 red tokens (gain: 3 tokens overall)
r : changes 1 red token into 3 white tokens (gain: 2 tokens overall)
We know that Juan does 11 trades, so we can say:
w + r = 11
Overall, Juan started with 4 tokens and ends with 31... so, gain of 27 tokens.
We can model this as:
3w + 2r = 27
(3w because each w transaction, he gains 3 tokens, 2r because every r transaction, he gains 2 tokens).
From first equation we get r = 11 - w, which we place in the second equation:
3w + 2 (11 - w) = 27
3w + 22 - 2w = 27
w = 5, so r = 6 (from first equation).
Now, we know Juan did 5 w transactions and 6 r transactions. But how many token of each color does he have?
Start: 4W (4 White chips)
He does 4 w transactions, he now has 16R tokens
He does 6 r transactions, he now has 10 (16-6) R tokens, plus 18 W tokens
He does another w transaction, he now has 14 R (10 + 4), plus 17 W(18-1) tokens
He did 11 transactions, and he has 31 tokens at the end, out of which 14 are red.