# CAESAR CIPHER

This is my python code which works effectively
when I run it on codechef run button during yesterday competition, it gave me precisely the answer. But when I decided to submit it, it was saying runtime error when I submitted yesterday.
Does codechef want a specific approach or algorithm to be used on a problem? Or what is the cause of this error please.

# cook your dish here

d = {“a”:1,“b”:2,“c”:3,“d”:4,“e”:5,“f”:6,“g”:7,“h”:8,“i”:9,“j”:10,“k”:11,“l”:12,“m”:13,“n”:14,“o”:15,“p”:16,“q”:17,“r”:18,“s”:19,“t”:20,“u”:21,“v”:22,“w”:23,“x”:24,“y”:25,“z”:26}
t = int(input())
for i in range(t):
c = int(input())
s = input()
t = input()
u = input()

# v = input()

``````l = []
ans = ""

kl = list(d.keys())
vl = list(d.values())

for ii in range(c):
dif = d[t[ii]]-d[s[ii]]
ad = d[u[ii]] + dif

if ad > 26: ad = ad%26
l.append(ad)
id = vl.index(ad)
ans += kl[id]
print(ans)
``````

@aduraseyi
For all problems, there is an expected time limit, sometimes an expected space limit too. While your code might be correct, it needs to solve the problem efficiently, otherwise you will get TLE (Time limit exceeded) error.

You can have a look at the editorial for better understanding.

Also, here is my code that i used to solve the problem.

``````# cook your dish here
for _ in range(int(input())):
l=""
n=int(input())
s=input()
t=input()
u=input()
dif=ord(t[0])-ord(s[0])
for i in u:
val=ord(i)+dif
if(val<97):
val+=26
elif(val>122):
val-=26
l=l+chr(val)
print(l)
``````

@codechief1 thank you. I now understand