predicts colors in python
#object for predicting color sequences.
class ColorPredictor:
def __init__(self, *colors):
self.memo = []
self.colors = set(colors)
self.colorcount = {elem:0 for elem in colors}
def __repr__(self):
return str(self.colorcount)
def read(self, elem):
if elem not in self.colors:
raise TypeError("Invalid color")
self.memo.append(elem)
self.colorcount[elem] += 1
def readstring(self, string):
for elem in string.split(" "):
self.read(elem)
def predict(self):
pass