1 lies on the table. In one move you may do either of the following:
- pick any card and increase its number by 1;
- pick any card and put down a copy of it showing the same number.
Given an integer target, return the fewest moves after which the numbers on all cards add up to at least target.target=10 → 5
Raise the card twice to 3 and make three copies: 3 + 3 + 3 + 3 = 12 ≥ 10. That is 5 moves, and fewer is not possible.
target=4 → 2
For example, raise the card to 2 and copy it once: 2 + 2 = 4, which takes 2 moves.
target=1 → 0
The single card already sums to 1, so no moves are needed.
target=10
5
Run checks the first 3 tests in your browser. Submit checks all 61 tests on the server, hidden ones included.