You have coins of values 1, 2 and 5. What is the smallest number of coins needed form the sum x exactly?
In this task, 1 \le x \le 10^{100}, i.e., x can be very large. The algorithm should be efficient in all cases.
In a file fastcoin.py
, implement a function count
that returns the smallest number of coins.
def count(x): # TODO if __name__ == "__main__": print(count(13)) # 4 print(count(12345)) # 2469 print(count(1337**9)) # 2730314408854633746890878156