Getting a wrong answer in Bytelandian gold coins problem

test_case = 10
arr = []
for i in range(0,test_case):
coin = int(input())
dollars = int(coin/2) + int(coin/3) + int(coin/4)
if(dollars<coin):
dollars = coin
arr.append(dollars)
for i in range(0,test_case):
print(arr[i])


this is my code for the Bytelandian gold coins question with reference code COINS. Would you please solve my problem that on submission of this code to the problem i’m getting Wrong answer as feedback.

You need to consider converting the coins that result from the first conversion, then possibly converting those, etc.


Hint: It never hurts to convert a coin of value 12 or more. It never benefits to convert a coin less than 12.

Second hint: You’ll need to retain intermediate conversion results, to avoid calculating them over & over again, if you want to complete the process within the time limit.

You are dividing only given input into three parts and then checking it to be greater than given input.
What you have to do is check for divided parts too if they can be divided into more coins resulting more value than it is now.
A recursive solution is https://www.codechef.com/viewsolution/19564098