|
|
вернуться в форумWhy is this crashing to WA#1 (Python)? import sys def reverse(i): if len(i) == 1: return i else: return i[len(i)-1]+reverse(i[:len(i)-1]) def getReverseLine(s): start = 0 for i in range(len(s)): if (ord(s[i]) < 123 and ord(s[i]) > 64) and (ord(s[i]) < 91 or ord(s[i]) > 96): if i == len(s)-1: if start < i: s = s.replace(s[start:i+1], reverse(s[start:i+1])) else: if start < i: s = s.replace(s[start:i], reverse(s[start:i])) start = i+1 else: start += 1 return s lines = [] while True: line = sys.stdin.read() if line == '': break lines.append(getReverseLine(line)) text = '\n'.join(lines) print text |
|
|