Skip to content

Instantly share code, notes, and snippets.

@xaqrox
Created August 13, 2014 03:13
Show Gist options
  • Save xaqrox/b6bdf30b9e7d17e9aa53 to your computer and use it in GitHub Desktop.
Save xaqrox/b6bdf30b9e7d17e9aa53 to your computer and use it in GitHub Desktop.
Particle Clicker Calculator
import operator
class Trade:
def __init__(self, name, value, cost):
self.name = name
self.value = value
self.cost = cost
def updateValue(self, newValue):
self.value = newValue
def updateCost(self, newCost):
self.cost = newCost
def ratio(self):
return self.value/self.cost
class Group:
def __init__(self, name):
self.name = name
self.trades = {}
def addTrade(self, name, value, cost):
self.trades[name] = Trade(name, value, cost)
def printRatios(self):
ratios = {}
for t in self.trades:
trade = self.trades[t]
ratios[trade.name] = trade.ratio()
ratiosSorted = sorted(ratios.iteritems(), key=operator.itemgetter(1))
for n, r in ratiosSorted:
print "%s:\t%f" % (n, r)
def updateCost(self, name, cost):
self.trades[name].updateCost(cost)
def updateValue(self, name, value):
self.trades[name].updateValue(value)
hr = Group('hr')
hr.addTrade('phd', 30, 70.0)
hr.addTrade('post', 59, 260.3)
hr.addTrade('fellow', 90, 249.4)
hr.addTrade('prof', 175, 720.6)
hr.addTrade('nobel', 850, 1600.0)
hr.addTrade('summer', 1000, 8100.0)
hr.printRatios()
print
research = Group('research')
research.addTrade('cpsymm', 5, 3.6)
research.addTrade('jthing', 9 ,1.6)
research.addTrade('tlepto', 74, 2.0)
research.addTrade('beauty', 146, 3.1)
research.addTrade('wzboso', 290, 5.5)
research.addTrade('topq', 2100, 64.0)
research.addTrade('antih', 7200, 156.3)
research.addTrade('bmeson', 7200, 125.0)
research.addTrade('higgs', 14400, 217.5)
research.printRatios()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment