From 4d0be1b7b0b87b2a3f16069b86d3682ac475ddb3 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Sat, 27 Sep 2014 02:08:59 -0400 Subject: [PATCH] Solved Chocolate Feast --- chocolate_feast/chocolate_feast.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 chocolate_feast/chocolate_feast.py diff --git a/chocolate_feast/chocolate_feast.py b/chocolate_feast/chocolate_feast.py new file mode 100644 index 0000000..d93a500 --- /dev/null +++ b/chocolate_feast/chocolate_feast.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +# https://www.hackerrank.com/challenges/chocolate-feast + +import sys + +def num_chocolates(money, cost, exchange): + choco = money // cost + wrappers = choco + while wrappers > exchange: + exch_choco, wrappers = divmod(wrappers, exchange) + wrappers += exch_choco + choco += exch_choco + return choco + +def main(): + T = int(sys.stdin.readline()) + for _ in range(T): + [N, C, M] = [ int(x) for x in sys.stdin.readline().split() ] + print(num_chocolates(N, C, M)) + +if __name__ == '__main__': + main() \ No newline at end of file