Last active
May 24, 2021 04:24
-
-
Save adithyabsk/3f292db8c87704d8f2c4977e16ada2b4 to your computer and use it in GitHub Desktop.
NASA Perseverance Parachute Code
This file contains 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
"""Perseverence Parachute Cipher Python Solution | |
In Press: | |
* https://www.nytimes.com/2021/02/24/science/nasa-mars-parachute-code.html | |
* https://www.theguardian.com/science/2021/feb/23/dare-mighty-things-hidden-message-found-on-nasa-mars-rover-parachute | |
* https://www.cmu.edu/news/stories/archives/2021/march/mars-rover-code.html | |
Output: | |
DARE¿¿¿¿ | |
MIGHTY¿¿ | |
THINGS¿¿ | |
34°11'58'' N 14°118'10'' W | |
""" | |
def bit2int_arr(msg): | |
rslt = [] | |
while len(msg) > 0: | |
msg = msg[3:] # Skip the first 3 characters (padding) | |
rslt.append(int(msg[:7], 2)) # Convert the binary string to an integer | |
msg = msg[7:] # Skip 7 characters (we just read this char) | |
return rslt | |
def intarr2str(msg): | |
return "".join([chr(i+64) for i in msg]) # Add 64 (ASCII offset) | |
def solve(): | |
msg = [ | |
# inner ring (starts at n=1) | |
"00000001000000000001000001001000000001010001111111111111111111111111111111111111", | |
# middle ring 1 (starts at n=41) | |
"00000011010000001001000000011100000010000000010100000001100100011111111111111111", | |
# middle ring 2 (starts at n=21) | |
"00000101000000001000000000100100000011100000000111000001001100011111111111111111", | |
] | |
# outer ring (starts at n=76) | |
outer = "00001000100000001011000011101000000011100001110110000000101000000111110000010111" | |
for m in msg: | |
print(intarr2str(bit2int_arr(m))) | |
coords = bit2int_arr(outer) | |
degrees = u"\N{DEGREE SIGN}" | |
print( | |
f"{coords[0]}{degrees}" | |
f"{coords[1]}'" | |
f"{coords[2]}'' " | |
f"{chr(coords[3]+64)} " | |
f"{coords[4]}{degrees}" | |
f"{coords[5]}'" | |
f"{coords[6]}'' " | |
f"{chr(coords[7]+64)}" | |
) | |
if __name__ == "__main__": | |
""" | |
Original Code by /u/rdtwt1 | |
Outer Ring Solved by /u/tend0g | |
Comments + Updated Code by /u/adithyabsk | |
https://www.reddit.com/r/nasa/comments/lpy2fa/does_the_parachute_for_perseverance_have_some/goedts0/ | |
""" | |
solve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment