#A Little Off The Top, Python 2
A Little Off The Top, Python 2
import math, sys
total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:])
def get_equal_share(total_degrees, people):
return int(math.ceil(total_degrees/float(people)))
def noms(total_degrees, degrees_left, people):
bid = get_equal_share(total_degrees,people)-1
return min(degrees_left, bid)
print noms(total_degrees, degrees_left, people_left)
Since the "perfect" algorithm tries to split the cake evenly between the bots, we're going to take just a sliver less than that. Demands its full fair share of the overall cake, even in subsequent rounds, but skews that number upward since it's based on how many people are left.
I haven't programmed in Python in a long while, so let me know if my code is broken...