-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuestion.py
More file actions
33 lines (28 loc) · 1.06 KB
/
Question.py
File metadata and controls
33 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from collections import deque
class Question:
def __init__(self, given, answer):
self.given = given
self.answer = answer
fiveZeroes = [0] * 5
self.history = deque(fiveZeroes, maxlen=5)
def getScore(self):
weights = [.1, .2, .7, .8, .8]
if not self.history:
return -1
else:
weightedSum = sum([score * weight for score, weight in zip(self.history, weights[:len(self.history)])]) / sum(weights[:len(self.history)])
"""
if len(self.history) < 3 and weightedSum > .2:
return weightedSum - .2
"""
return weightedSum
def getRight(self):
self.history.extend([1])
def getWrong(self):
self.history.extend([0])
def getProgress(self):
length = 40
given = self.given if len(self.given) < length else self.given[:length - 3] + "..."
if len(self.history) > 0:
return "{:40s}{:3.2f}:".format(given, self.getScore()) + "#" * int(10 * self.getScore())
return "{:40s} NYT:".format(given)