Last active
August 13, 2018 19:31
-
-
Save AndrewKiri/0d07a34830b1a9aab8650544de0a4623 to your computer and use it in GitHub Desktop.
test py py py (first task)
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 donate(monthly_profits): | |
def lowest(a, b, c): | |
if a > b > c: | |
return "C" | |
elif b > a > c: | |
return "C" | |
elif c > b > a: | |
return "A" | |
elif c > a > b: | |
return "B" | |
elif b > c > a: | |
return "A" | |
elif a == b == c: | |
return "A" | |
elif a == b & a != c: | |
return "A" | |
elif b == c & b != a: | |
return "B" | |
elif c == a & a != b: | |
return "A" | |
charities = { | |
"A": 0, | |
"B": 0, | |
"C": 0 | |
} | |
result = [] | |
for month in monthly_profits: | |
letter = lowest(int(charities["A"]), int(charities["B"]), int(charities["C"])) | |
charities[letter] = charities[letter] + month | |
result.append(letter) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment