Advertisement
hoanmalai

Cipher

Dec 5th, 2022
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. n, k = map(int, input().split())
  2. s = input()
  3. b = s[0]
  4. for i in range(1, n):
  5.   if i < k:
  6.     b += str(int(s[i]) ^ int(s[i-1]))
  7.   else:
  8.     b += str(int(s[i]) ^ int(s[i-1]) ^ int(b[i-k]))
  9.  
  10. print(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement