oranges oranges on the table. Each day you choose exactly one action:
- eat one orange;
- if the number of remaining oranges x is divisible by 2, eat x / 2 of them;
- if x is divisible by 3, eat 2x / 3 of them.
Return the fewest days needed to eat all the oranges.oranges=6 → 3
6 is divisible by 3: eat 4, leaving 2. Then eat half, leaving 1. The last orange goes on day three.
oranges=11 → 5
Eat one at a time: 11 → 10 → 9, then two thirds: 9 → 3, again: 3 → 1, and the last orange. That is 5 days.
oranges=1 → 1
oranges=6
3
Run checks the first 3 tests in your browser. Submit checks all 235 tests on the server, hidden ones included.