The fewest bags of rice
Write code · Challenge · §7.5, §8.6 The math helper as parts
You deliver exactly n kg of rice using 3 kg bags and 5 kg bags. Complete the function rice(n), which returns the smallest possible number of bags. If you cannot make exactly n kg, return -1. For 18 kg, three 5 kg bags and one 3 kg bag make 4 bags.
Starter code
def rice(n):
# Write your code here
pass
print(rice(18))Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.