Skip to content

Instantly share code, notes, and snippets.

@kscottz
Created January 11, 2016 06:03
Show Gist options
  • Save kscottz/a8dae8d857402e51fb41 to your computer and use it in GitHub Desktop.
Save kscottz/a8dae8d857402e51fb41 to your computer and use it in GitHub Desktop.
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