Skip to content

Instantly share code, notes, and snippets.

@Shrhawk
Created January 28, 2016 11:41
Show Gist options
  • Save Shrhawk/a8f6c9bfd35d44dfb208 to your computer and use it in GitHub Desktop.
Save Shrhawk/a8f6c9bfd35d44dfb208 to your computer and use it in GitHub Desktop.
def toffee_calculator(rupees=0):
toffee_price = 1
total_toffees = 0
total_toffees = rupees * toffee_price
extra_toffees = extra_toffees_calculation(total_toffees)
extra_toffees = (total_toffees + extra_toffees) / 3
return total_toffees + extra_toffees
def extra_toffees_calculation(toffees, acutal_extra=0):
extra_toffees = int(toffees / 3)
acutal_extra = acutal_extra + extra_toffees
if extra_toffees % 3 == 0:
return acutal_extra
return extra_toffees_calculation(extra_toffees, acutal_extra)
toffee_calculator(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment