From 5563eebe527c335059516c9b14fb8063b727f565 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Sun, 2 Sep 2018 16:32:00 -0500 Subject: Changing money algo done. --- .../sources/changingmoney.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 AlgoDesignAndTechniqueEdxPython/sources/changingmoney.py (limited to 'AlgoDesignAndTechniqueEdxPython/sources') diff --git a/AlgoDesignAndTechniqueEdxPython/sources/changingmoney.py b/AlgoDesignAndTechniqueEdxPython/sources/changingmoney.py new file mode 100644 index 0000000..5369b9e --- /dev/null +++ b/AlgoDesignAndTechniqueEdxPython/sources/changingmoney.py @@ -0,0 +1,17 @@ +# Uses python3 +def getNumOfCoins(m): + # coins with denominations of 1, 5, and 10 + coinCount = 0 + remainder = 0 + if m / 10 == 0 & m % 10 == 0: + return m / 10 + coinCount = coinCount + int(m / 10) + remainder = m % 10 + if remainder >= 5: + return coinCount + 1 + remainder - 5 + else: + return coinCount + remainder + + +m = int(input()) +print(getNumOfCoins(m)) \ No newline at end of file -- cgit v1.2.3