Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First, brute force (dark force?) solution in Clear category for Unfair Dice by Thenbacker
from itertools import combinations_with_replacement
def winning_die(enemy_die):
for combination in combinations_with_replacement(range(1, 18), len(enemy_die)):
total = 0
if sum(combination) == sum(enemy_die):
#check if the proposed die will be winning using the approach in
#the grader/assert
for p in combination:
for e in enemy_die:
if p > e:
total += 1
elif p < e:
total -= 1
if total > 0:
return list(combination)
return []
Nov. 13, 2016
Comments: