Here is my code for the Adding Sevens problem spoj.pl/problems/ANARC08B/
led2Num = {'059' : '0','010' : '1','093' : '2','079' : '3','106' : '4','103' : '5','119' : '6','011' : '7','127' : '8','111' : '9' }
num2Led = {'0' : '059','1' : '010','2' : '093','3' : '079','4' : '106','5' : '103','6' : '119','7' : '011','8' : '127','9' : '111' }
while True:
data = raw_input()
if data == 'BYE' :break
op1, op2 = data[:-1].split('+')
num1 = ''.join( [ led2Num[ op1[ x : x+3 ] ] for x in range( len( op1 ) )[::3] ] )
num2 = ''.join( [ led2Num[ op2 [x : x+3 ] ] for x in range( len( op2 ) )[::3] ] )
answer = ''.join( [ num2Led[ digit ] for digit in str( eval( num1 + '+' + num2 ) ) ] )
print data+answer
This code runs perfectly fine on my comp in both ways:
1. run the program from console and type the input values by hand
2. put the input values in a file and pipe it to the program
--- Here is the output i get
[ans@ans-lappy Desktop]$ cat ip | python num.py
010+093106=093103
010093+106=010119
but i get the NZEC error after submitting
some one please guide me where i'm going wrong
thanks in advance