Skip to content

Instantly share code, notes, and snippets.

@suguby
Created April 23, 2019 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suguby/db386034e7ceed97065a1ca2fec2b4f0 to your computer and use it in GitHub Desktop.
Save suguby/db386034e7ceed97065a1ca2fec2b4f0 to your computer and use it in GitHub Desktop.
recurrence_cocktail
def recurrence_cocktail(ml):
if ml <= 2:
return 1, 1
half_dose = ml // 2
second_part_spirit, second_part_water = recurrence_cocktail(ml=half_dose)
return ml * .2 + second_part_spirit, ml * .3 + second_part_water
spirit, water = recurrence_cocktail(ml=1000)
spirit, water = map(int, (spirit, water))
print(spirit, water, int(spirit/(spirit + water) * 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment