1 / 2
Sep 2014

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/1

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()
  • created

    Sep '14
  • last reply

    Sep '14
  • 1

    reply

  • 701

    views

  • 2

    users

  • 2

    links

This "NZEC error" happens because, your pgm terminated with few sort of run-time error. Some reasons are as follow:

1- When you trying to convert something that is not a whole numbers (like, empty or non-empty strings).
2- Not sufficient elements in a and a list-index-out-of-bounds error comes (possibly at the expression, as the value calculated doesn't seem like being used elsewhere, and perhaps not be really present in the input.)
3- Wrong argument for math.