Skip to content

Instantly share code, notes, and snippets.

@ajitid
Created June 12, 2017 18:29
Show Gist options
  • Save ajitid/615db62adb0393521afd78a5ae962b46 to your computer and use it in GitHub Desktop.
Save ajitid/615db62adb0393521afd78a5ae962b46 to your computer and use it in GitHub Desktop.
def change(s, a, b):
s = s[:a - 1] + b + s[a:]
return s
def substr(s, b, c, d):
a = list(s[b - 1:c])
l = list(map(lambda x: ord(x), a))
min_ascii = min(l)
while ord(a[0]) != min_ascii:
a.insert(0, a.pop())
print(a[d - 1])
s = input()
n = int(input())
for i in range(n):
x = input()
if x[0] == '0':
a = int(x[2:-2])
b = x[-1]
s = change(s, a, b)
elif x[0] == '1':
b, c, d = x[2:].split()
substr(s, int(b), int(c), int(d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment