Skip to content

Instantly share code, notes, and snippets.

@GabeOchieng
Forked from adithyabsk/parachute.py
Created March 15, 2021 13:41
Show Gist options
  • Save GabeOchieng/ef8d11aa957ff04bea3d974f1a31e3a4 to your computer and use it in GitHub Desktop.
Save GabeOchieng/ef8d11aa957ff04bea3d974f1a31e3a4 to your computer and use it in GitHub Desktop.

Revisions

  1. @adithyabsk adithyabsk revised this gist Feb 23, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions parachute.py
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ def solve():
    # 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)))
  2. @adithyabsk adithyabsk revised this gist Feb 23, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion parachute.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    """Python Script to solve the perseverence parachute code
    """Python Script to solve the perseverence parachute
    code
    Output:
    DARE¿¿¿¿
  3. @adithyabsk adithyabsk revised this gist Feb 23, 2021. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions parachute.py
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,4 @@
    """Script to solve the perseverence parachute code
    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/
    """Python Script to solve the perseverence parachute code
    Output:
    DARE¿¿¿¿
    @@ -51,4 +47,10 @@ def solve():


    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()
  4. @adithyabsk adithyabsk created this gist Feb 23, 2021.
    54 changes: 54 additions & 0 deletions parachute.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    """Script to solve the perseverence parachute code
    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/
    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 = "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__":
    solve()