POINTS_TABLE = [3, 5, 7, 1]
function score(answer) {
result = 0
for i in 0..4
result += POINTS_TABLE[answer[i]]
return result
}
answer = [1, 2, 1, 0]
s = score(answer)
The sum performed is 5 + 7 + 5 + 3 = 20. It uses the values from the input as the indexes to read from the POINTS_TABLE.
This is the style of the answer I'm trying to work out: \begin{equation} score(answer) = \sum_{i=1}POINTS\_TABLE_{answer_i} \end{equation}