Created
August 26, 2019 09:50
-
-
Save anapaulagomes/0fa5d35d9c8d1786c9b4f43de5f5e41e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
CRATE_SIZE = 24 | |
def beer_formula(rsvps): | |
minimum = 1.3 | |
maximum = 2 | |
return int(minimum * rsvps), int(maximum * rsvps) | |
def soft_drinks_formula(rsvps): | |
minimum = 0.8 | |
maximum = 1.2 | |
return int(minimum * rsvps), int(maximum * rsvps) | |
def calculate(lower_bound, upper_bound): | |
for size in range(0, upper_bound, CRATE_SIZE): | |
if lower_bound <= size <= upper_bound: | |
return size | |
return | |
print(f'Considering a crate of size {CRATE_SIZE}...\n') | |
print(f'PERSONS\tBEERS\tSOFT DRINKS') | |
for persons in range(30, 150, 20): | |
beers = calculate(*beer_formula(persons)) | |
soft_drinks = calculate(*soft_drinks_formula(persons)) | |
print(f'{persons}\t{int(beers/CRATE_SIZE)}\t{int(soft_drinks/CRATE_SIZE)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment