Rice bags
Write code · Challenge · §2.3 Turning conditions into code
You deliver exactly n kg of rice in 3 kg bags and 5 kg bags. You may use any number of each kind, including none of one kind. Complete the function solution, which returns the smallest number of bags you can use.
If you cannot make exactly n kg, return -1.
Function
solution(n)
Constraints
nis an integer from 1 to 1,000,000,000.
Examples
| n | result |
|---|---|
18 | 4 |
4 | -1 |
Starter code
def solution(n):
answer = -1
return answerSolve 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.