-
-
Save whs/1101601 to your computer and use it in GitHub Desktop.
Hackathon r2-7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input = "\x4c\x9a\x59\x3a\x35\x89\x91\x24\x5a\x9a\x5d\x3a\x35\x29\x95\x2b\x53\x8c\x35\xba\x94\xca\xd5\x2d\x4d\xae\x59\x92\x45\x6a\xd1\x21\x4c\x9a\x59" | |
| #input="\x53\xac\x3d\x7a\xc4" | |
| pos = 0 | |
| out="" | |
| for i in input: | |
| # do a circular right shift | |
| b = list(bin(ord(i)).split("0b")[1]) | |
| # pad to 8 bits | |
| while len(b) < 8: | |
| b.insert(0, "0") | |
| print pos, b | |
| i=0 | |
| # right shift | |
| while i < pos: | |
| b.insert(0, b.pop()) | |
| i += 1 | |
| print b | |
| pos += 1 | |
| decoded = chr(int("".join(b), 2)) | |
| # reverse it! | |
| i=0 | |
| start = 65 | |
| end = 90 | |
| while i <= 26: | |
| if decoded == chr(start+i): | |
| decoded = chr(end-i) | |
| break | |
| i += 1 | |
| out += decoded | |
| print out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great
I use collections:deque to rotate (right shift)