Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Exceptional solution in Clear category for Unfair Dice by veky
def winning_die(enemy):
def explore(rlen, rlist, rsum, rmin):
if rlen:
for one in range(rmin, 1 + rsum // rlen) if rlen > 1 else [rsum]:
explore(rlen - 1, rlist + [one], rsum - one, one)
elif sum((p > e)-(p < e) for p in rlist for e in enemy) > 0:
raise StopIteration(rlist)
try:
explore(len(enemy), [], sum(enemy), 1)
except StopIteration as found:
return found.args[0]
else:
return []
June 4, 2014
Comments: