Skip to content

Instantly share code, notes, and snippets.

@MrValdez
Created January 3, 2015 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MrValdez/6d07ee0d8a807ef17380 to your computer and use it in GitHub Desktop.
Save MrValdez/6d07ee0d8a807ef17380 to your computer and use it in GitHub Desktop.
import random
random.seed(0)
def MakeData():
Data = ["Spam"] * 5
Data.extend(["Eggs"] * 2)
Data.extend(["Ham"] * 2)
return Data
def NonDeterministic(Data):
justSpam = set(Data) & set(["Spam"])
IloveHam = set(Data) & set(["Ham"])
TastyEgg = set(Data) & set(["Eggs"])
Breakfast = justSpam | IloveHam | TastyEgg
DeliciousFactor = random.random()
return Breakfast, DeliciousFactor
def Deterministic(Data):
justSpam = [food for food in Data if food == "Spam"]
IloveHam = [food for food in Data if food == "Ham"]
TastyEgg = [food for food in Data if food == "Eggs"]
Breakfast = []
Breakfast.extend([justSpam[0], IloveHam[0], TastyEgg[0]])
DeliciousFactor = random.random()
return Breakfast, DeliciousFactor
menu = MakeData()
print (NonDeterministic(menu))
print (Deterministic(menu))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment