Can somebody point out the cause for NZEC error in this two problems?. If somebody could list out the errors with example it would be a great help for all the pythonists.
1.Alphacode:http://www.spoj.com/SPOJ/problems/ACODE/
dic = {}
def main():
while True:
line = int(raw_input())
if line == 0:break
print dp(str(line))
dic.clear()
def dp(line):
if line in dic:
return dic[line]
else:
if len(line) > 2:
a = chk(line[0])*dp(line[1:]) + chk(line[:2])*dp(line[2:])
elif len(line) > 1:
a = chk(line[0])*dp(line[1]) + chk(line)
else:
a = chk(line)
dic[line] = a
return a
def chk(word):
if word[0] == '0':
return 0
if int(word) <= 26 and int(word) > 0:
return 1
else:
return 0
main()
2.Training for final http://www.spoj.com/SPOJ/problems/TRIKA/
from sys import stdin
def main():
n, m = map(int,stdin.readline().rstrip().split())
x, y = map(int,stdin.readline().rstrip().split())
arr = []
for r in range(n):
row = map(int,stdin.readline().rstrip().split())
arr.append(row)
i, j = 1, 0
while i <= n-1:
arr[i][j] = arr[i-1][j] - arr[i][j]
i+=1
i, j = 0, 1
while j <= m-1:
arr[i][j] = arr[i][j-1] - arr[i][j]
j+=1
i = 1
while i <= n-1:
j = 1
while j <= m-1:
arr[i][j] = max(arr[i-1][j],arr[i][j-1]) - arr[i][j]
j+=1
i+=1
if arr[i-1][j-1]<0:print 'N'
else:
print 'Y ' + str(arr[i-1][j-1])
main()