This is the problem, for which the code is below written in Python 2.7.6 This is the example Input and output for the same problem.
这是代码,在我的机器上工作正常。但是在Codechef中提交它时会出现一个名为NZEC错误的问题,我不熟悉并且不知道如何调试它。
##Reverse Function
def reverse(member):
if len(member) <= 1:
return member
return reverse(member[1:]) + member[0]
##Sum of Position
def positionsum(member):
checker = len(member)/2
realsum = 0
while checker != -1:
realsum = checker + realsum + 1
checker = checker - 1
return realsum
##Sum of those values at that Position
def valuesum(member):
checker = len(member)/2
sumis = 0
while checker != -1:
sumis = int(member[checker]) + sumis
checker = checker - 1
return sumis
stop = 0
##Entering Cases
inp = int(raw_input(''))
lst = list()
##INPUT OF ALL THE MEMBERS & STRIPS
while (inp > stop):
member = ''
##Entering Strips
strips = int(raw_input(''))
##Entering Members
member = raw_input('')
if len(member) > strips:
print 'Wrong Input'
continue
lst.append(member)
stop = stop + 1
print lst
##CHECKING FOR ELIGIBILITY
for member in lst:
new_string = ''
real_sum = 0
sum_is = 0
if len(member)%2 != 0 and member[0] == '1':
new_string = reverse(member)
real_sum = positionsum(member)
sum_is = valuesum(member)
if member == new_string and real_sum == sum_is:
print 'yes'
else:
print 'no'
if member[0] != '1' or len(member)%2 == 0:
print 'no'