Last active
October 26, 2017 09:22
-
-
Save olligobber/4eac470511c61be0e67c to your computer and use it in GitHub Desktop.
Person A can staple 100 magazines in 5 minutes and fold 100 letters in 10 minutes. Person B can staple 100 magazines in 10 minutes and fold 100 letters in 5 minutes. Person C can staple 100 magazines in 8 minutes and fold 100 letters in 6 minutes. If they work together, how long will it take for them to staple 100 magazines and fold 100 letters?
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
total=100 | |
def A(m,l): | |
return 5*m + 10*l | |
def B(m,l): | |
return 10*m + 5*l | |
def C(m,l): | |
return 8*m + 6*l | |
best = 5*total | |
for p in range(0,total+1): | |
for r in range(0,total+1-p): | |
for q in range(0,total+1): | |
for s in range(0,total+1-q): | |
best = min(best, max(A(p,q), B(r,s), C(total-p-r,total-q-s))) | |
print(best/total) # 3.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment