From 6194b3796f785150f88d1576c3f0413817aeac40 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Sat, 27 Sep 2014 12:37:40 -0400 Subject: [PATCH] Solved Filling Jars --- filling_jars/filling_jars.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 filling_jars/filling_jars.py diff --git a/filling_jars/filling_jars.py b/filling_jars/filling_jars.py new file mode 100644 index 0000000..bb6db33 --- /dev/null +++ b/filling_jars/filling_jars.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +# https://www.hackerrank.com/challenges/filling-jars + +import sys + +def nextints(): + return [ int(x) for x in sys.stdin.readline().split() ] + +def new_candies(start, end, new_per_jar): + return (end - start + 1) * new_per_jar + +def main(): + total = 0 + [num_jars, num_ops] = nextints() + for _ in range(num_ops): + [start, end, new_per_jar] = nextints() + total += new_candies(start, end, new_per_jar) + print(total // num_jars) + +if __name__ == '__main__': + main() \ No newline at end of file