PY
py
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
# Created by Oma Falk
def calculateScores(func):
# score.state has access to initial values via func aka initializeBoard
# and can edit them
# no need to pass this values in recursion
def score():
score.called += 1
if score.called == 1:
score.state = func()
word, wordList, result, initials = score.state
if not wordList:
return score.state
c = wordList.pop(0)
idx = initials.find(c)
if idx >-1:
result[idx]+=1
return score()
score.called = 0
return score
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run