Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def swap_pair(string, pair):
- text = string.replace(pair[0], pair[1])
- return text
- def swap_adj(string):
- if len(string) % 2 == 1:
- string = string[0:-1]
- text = ""
- odds = ""
- evens = ""
- for i in range(len(string)):
- if i % 2 == 1:
- odds += string[i]
- else:
- evens += string[i]
- for i in range(len(odds)):
- text += odds[i]
- text += evens[i]
- return text
- def finalize(sting):
- text = sting
- while True:
- if text[0] == " ":
- text = text[1:]
- elif text[-1] == " ":
- text = text[:-1]
- else:
- break
- text = swap_pair(text, "z ")
- text = text[-1].upper() + text[:-1].lower() + "A+."
- return text
- print(finalize(" CORE: zs "))
- def decode_string(string, pair):
- print("Original", string)
- swapped_pair = swap_pair(string,pair)
- swapped_adj = swap_adj(swapped_pair)
- print("Final: ", finalize(swapped_adj))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement