Hi @vague0 if I am not mistaken I think there are two things that matter in this problem:
- The money should be even for it to be divided equally.
- The division should be able to take place in the form of coins with denominations.
To explain point number 2, take the following example - 3 coins of 2 rupees each. Here, the total amount is rupees 6 which is even (and hence satisfies the first point). However, when you try to divide it between two people you won’t be able to since you have 3 coins and it isn’t possible to have 1.5 coins being given to each person.
So this is the error in your code. Hope this helps!
Thanks for the reply. I completely overlooked the second point while reading the question before. It finally worked.