|
|
back to boardRTE #10 where am i wrong?? def chk(m): for i in range(0, int(len(m)/2)): if m[i] != m[len(m)-i-1]: if m[i] > m[len(m)-i-1]: m[len(m)-i-1] = m[i] else: m[len(m)-i-1] = m[i] m = inc(m, len(m)-i-2) chk(m) return m def inc(y, x): if y[x]<9: y[x] += 1 else: y[x] = 0 inc(y, x-1) return y v = list(input()) l = list(map(int, v)) if(len(v)==1): print(v[0]) else: l = chk(l) print("".join(str(o) for o in l)) Re: RTE #10 where am i wrong?? I thought index reaching end may be a problem but that can never happen can it?, TLE may be ok but why RTE??? Re: RTE #10 where am i wrong?? It is because of too many recursion i presume trying to find a work around... def chk(m): for i in range(0, int(len(m)/2)): if m[i] != m[len(m)-i-1]: if m[i] > m[len(m)-i-1]: m[len(m)-i-1] = m[i] else: m[len(m)-i-1] = m[i] m = inc(m, len(m)-i-2) chk(m) return m def inc(y, x): if y[x]<9: y[x] += 1 else: y[x] = 0 inc(y, x-1) return y v = list(input()) l = list(map(int, v)) if(len(v)==1): print(v[0]) else: l = chk(l) print("".join(str(o) for o in l)) |
|
|