Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created August 31, 2018 12:06
Show Gist options
  • Save mauricioaniche/bcacd639543fd6e28a4e5c7c44a1ac4a to your computer and use it in GitHub Desktop.
Save mauricioaniche/bcacd639543fd6e28a4e5c7c44a1ac4a to your computer and use it in GitHub Desktop.
def calculate(small, big, total):
maxBigBoxes = total // 5
bigBoxesWeCanUse = maxBigBoxes if maxBigBoxes < big else big
total -= (bigBoxesWeCanUse * 5)
if(small < total):
return(-1)
else:
return(total)
def test_total_is_higher():
assert calculate(1, 1, 10) == -1
def test_need_for_big_and_small_bars():
assert calculate(5, 3, 17) == 2
def test_only_big_bars():
assert calculate(5, 3, 10) == 0
def test_only_small_bars():
assert calculate(4, 2, 3) == 3
def test_boundary_1():
assert calculate(2, 3, 17) == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment