Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NASA Perseverance Parachute Code
"""Python Script to solve the perseverence parachute
code
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