Skip to content

Instantly share code, notes, and snippets.

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))
@suguby
suguby / probe
Created December 21, 2017 10:25
class Cat:
def __init__(self, name):
self.name = name
self.mood = 50
self.fullness = 50
def sleep(self):
self.mood += 5
self.fullness -= 10
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import time
def add(x,y):
return x+y
def max(x,y):
if x<y: return y
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sprint_lib
class TailRecurseException:
def __init__(self, args, kwargs):
self.args = args
self.kwargs = kwargs
def tailcall(g):