File size: 718 Bytes
f2ec360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

getAnsweredQuestions = lambda questions: [
    q for q in questions if q["status"] == "answered"
]
getUnansweredQuestions = lambda questions: [
    q for q in questions if q["status"] == "unanswered"
]
getSubQuestions = lambda questions: [q for q in questions if q["type"] == "subquestion"]
getHopQuestions = lambda questions: [q for q in questions if q["type"] == "hop"]
getLastQuestionId = lambda questions: max([q["id"] for q in questions])


def markAnswered(questions, id: int):
    for q in questions:
        if q["id"] == id:
            q["status"] = "answered"


def getQuestionById(questions, id: int):
    q = [q for q in questions if q["id"] == id]
    if len(q) == 0:
        return None
    return q[0]