Created
January 11, 2016 06:03
-
-
Save kscottz/a8dae8d857402e51fb41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools as it | |
def make_cards(n,m=[0,100,200,300,400]): | |
values = [n+mm for mm in m] | |
cards = [] | |
for card in it.permutations(values): | |
cards.append(list(card)) | |
return cards | |
def run_alg(cards,alg): | |
results = [] | |
for card in cards: | |
price = alg(card) | |
results.append({"deck":card,"price":price}) | |
return results | |
def calculate_avg(results): | |
prices = [p["price"] for p in results] | |
return sum(prices)/float(len(prices)) | |
def my_alg(cards): | |
# CODE GOES HERE | |
return(cards[0]) | |
def __main__(): | |
cards = make_cards(1000) | |
results = run_alg(cards,my_alg) | |
print calculate_avg(results) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment