Skip to content

Commit

Permalink
Solved Filling Jars
Browse files Browse the repository at this point in the history
  • Loading branch information
letitz committed Sep 27, 2014
1 parent b635aaa commit 6194b37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions filling_jars/filling_jars.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6194b37

Please sign in to comment.