Cipher Discussions | Algorithms | HackerRank
  • + 0 comments
    def cipher(k, s):
        # Write your code here
        if(k==0):
            return s
        S=s[0]
        for i in range(1,len(s)-(k-1)):
            S+=str(int(s[i])^int(s[i-1])^(0 if i<k else int(S[i-k])))         
        return S