1>>> import js2py
2>>> f = js2py.eval_js('function f(x) {return x + x}')
3>>> f(2)
44
5>>> f()
6nan
7>>> f(f)
8function f(x) { [python code] }function f(x) { [python code] }
1def numberOfSubArray(arr):
2 data = {}
3 n = len(arr)
4 maxAmount = 1
5 for i in range(1, n + 1):
6 for j in range(i):
7 s = sum(arr[j:i])
8 if s not in data:
9 data[s] = [i - 1, 1]
10 elif data[s][0] < j:
11 data[s][1] += 1
12 if data[s][1] > maxAmount: maxAmount = data[s][1]
13 data[s][0] = i - 1
14
15 return maxAmount