Skip to content

Instantly share code, notes, and snippets.

@whoizit
Created April 4, 2020 13:28
Show Gist options
  • Save whoizit/15b511c793acdfe3aa1fab8567d95658 to your computer and use it in GitHub Desktop.
Save whoizit/15b511c793acdfe3aa1fab8567d95658 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# http://who.int/gpsc/5may/Guide_to_Local_Production.pdf
from sys import argv, exit
if len(argv) == 1:
print(
'''\
{} bottle_volume want_alcohol% have_alcohol% have_peroxide% have_glycerol%
Example: {} 250 60 99.7 3 86\
'''.format(
argv[0], argv[0]
)
)
exit()
bottle_volume = float(argv[1])
want_alcohol_percent = float(argv[2])
have_alcohol_percent = float(argv[3])
have_peroxide_percent = float(argv[4])
have_glycerol_percent = float(argv[5])
alcohol = bottle_volume * (want_alcohol_percent / have_alcohol_percent)
glycerol = bottle_volume * (1.45 / have_glycerol_percent)
peroxide = bottle_volume * (0.125 / have_peroxide_percent)
water = bottle_volume - alcohol - peroxide - glycerol
print(
'''\
% ml
Bottle {3:5}
Alcohol {0:5} {4:5}
Peroxide {1:5} {5:5}
Glycerol {2:5} {6:5}
Water {7:5}\
'''.format(
have_alcohol_percent,
have_peroxide_percent,
have_glycerol_percent,
round(bottle_volume),
round(alcohol),
round(peroxide),
round(glycerol),
round(water),
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment