def compileResultDict(roll_n_list): """ Given a complete list of unique ways to roll n dice: 1) summarize() each roll 2) Count how many repeats the roll has (mississippi permutations), i.e. how many times it should occur out of 6^n trials 3) Figure out the resulting score of the roll using result() 4) Add result:repeats to resultDict """ resultDict = {} for roll in roll_n_list: summary = summarize(roll) repeats = factorial(sum(summary.values())) for i in summary.values(): repeats = int(repeats/factorial(i)) res = result(summary) if res["score"] ==0: # if there is no score, then don't # bother counting remaining dice. key = (0,0) else: key = (res["score"], res["dice"]) if key in resultDict.keys(): resultDict[key]+=repeats else: resultDict[key]=repeats return(resultDict)
def compileResultDict(roll_n_list): resultDict = {} for roll in roll_n_list: res = result(summarize(roll)) if res["score"] ==0: key = (0,0) else: key = (res["score"], res["dice"]) if key in resultDict.keys(): resultDict[key]+=1 else: resultDict[key]=1 return(resultDict)