Created
August 31, 2018 12:06
-
-
Save mauricioaniche/bcacd639543fd6e28a4e5c7c44a1ac4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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