### esy's blog

By esy, history, 6 weeks ago,

I have this code for problem 1B in python but in the test 7, runtime error occurs (Exit code 1). What is the problem?

def Diagnose (s) :
l=len(s); b=True; if (s[0]=="R") : if ("A" < s[1] < "Z") : ss=Type_1(s); else : for i in range(l): if (s[i]=="C"): ss=Type_2(s,i); b=False; break; if (b==True): ss=Type_1(s); else : ss=Type_1(s); return(ss);

def Type_1 (s) : #Example : BCS23 n=0;
while ( "A" <= s[n] <= "Z"): n=n+1; st=n;
col=0; for i in range (n) : col = col + (26**i) + ((ord(s[i])-ord("A")) * (26 ** (n-1))); n=n-1; col=str(col); ss=s[st:len(s)]; return ("R" + ss + "C" + col);

def Type_2 (s,i) : ss=""; st = str(s[1:i]); col = int(s[i+1:len(s)]); n=1; while ((col-(26**n)) > 0) : col = col — (26**n); n=n+1; c = 0; for i in range (n-1,-1,-1) : v=0; while ( col > (26**i) ) : col = col — (26**i); v=v+1; ss=ss+chr(v+ord("A")); ss=ss+st; return ss;

s = [None] * 10**5;

n = int(input()); for i in range(n): s[i]=input(); for i in range(n): s[i]=Diagnose(s[i]); for i in range(n): print(s[i]);

• -6

 » 6 weeks ago, # |   0 Auto comment: topic has been updated by esy (previous revision, new revision, compare).