Skip to content

Commit

Permalink
Merge pull request #99 from Kushagra-0801/master
Browse files Browse the repository at this point in the history
Solution to Issue #68
  • Loading branch information
the-vampiire authored Oct 19, 2018
2 parents 5386aa4 + f70aac9 commit 69a7775
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions intermediate/multiple-cash-registers_Kushagra-0801.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Solution to Issue #68 (Multiple Cash Registers)."""


def checkout_time(customers, cash_registers):
"""Find the time required for all the customers to checkout."""
if len(customers) < cash_registers:
return max(customers)

cashiers = [customers[i] for i in range(cash_registers)]
for i in customers[cash_registers:]:
cashiers[cashiers.index(min(cashiers))] += i
return max(cashiers)


def test():
"""Testing function."""
test_cases = [
([5, 1, 3], 1, 9),
([10, 3, 4, 2], 2, 10),
]
tests_passed = True

for i in test_cases:
try:
assert checkout_time(i[0], i[1]) == i[2]
except AssertionError:
tests_passed = False
print(i, checkout_time(i[0], i[1]), sep='\t')
continue

if tests_passed:
print('All Tests Passed.')
else:
print('All Tests NOT Passed.')


def main():
"""Actual Function."""
customers = list(map(int, input().split()))
cash_registers = int(input())
print(checkout_time(customers, cash_registers))


if __name__ == '__main__':
test()

0 comments on commit 69a7775

Please sign in to comment.