You are viewing a single comment's thread. Return to all comments →
def diff(arr): res=[] for i in range(len(arr)-1): res.append(abs(ord(arr[i])-ord(arr[i+1]))) return res def funnyString(s): st=list(s) rev=st[::-1] res1=diff(st) res2=diff(rev) return 'Funny' if res1==res2 else 'Not Funny'
or
def funnyString(s): for i in range(1, len(s)//2+1): if abs(ord(s[i])-ord(s[i-1])) != abs(ord(s[-i])-ord(s[-i-1])): return 'Not Funny' return 'Funny'
Seems like cookies are disabled on this browser, please enable them to open this website
Funny String
You are viewing a single comment's thread. Return to all comments →
or