Skip to content

Instantly share code, notes, and snippets.

@Tuhin-thinks
Created May 25, 2023 16:17
Show Gist options
  • Save Tuhin-thinks/3cb4e5479d516488ee49705339dd4c9a to your computer and use it in GitHub Desktop.
Save Tuhin-thinks/3cb4e5479d516488ee49705339dd4c9a to your computer and use it in GitHub Desktop.
"XSmPyeyHlTFjlvoIM.ZCuTlvrLkyVYjdJBqtdM SozWLxOrayj" The unscrambling process is as follows. 1. Set an index x to 0 2. Get the character at position x 3. If the character is a full stop, print your result string (omitting the first character) and stop 4. if not a full stop, add that character to your result string 5. Get the low order 4 bits of …
string = "XSmPyeyHlTFjlvoIM.ZCuTlvrLkyVYjdJBqtdM SozWLxOrayj"
# unscrambling start
x = 0
result = ""
while True:
ch = string[x]
if ch == '.':
print(result[1:]) # print the result string omitting the first character
break
else:
result += ch
bin_rep = bin(ord(ch))[1:]
low_4bin_value = bin_rep[-4:]
value = int(low_4bin_value, 2)
# add 1 to the number & check if the resultant number is odd/even
if (value & 1) == 1: # odd
x -= value + 1
else:
x += value + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment