Advertisement
Guest User

Untitled

a guest
Dec 17th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. import sys
  2.  
  3. # 2,4  b = a % 8
  4. # REDACTED: twiddle B
  5. # 7,5  c = a / (2^b)
  6. # REDACTED: twiddle B
  7. # REDACTED: twiddle B
  8. # 5,5  output b % 8
  9. # 0,3  a = a / 8
  10. # 3,0  if a != 0 then jump to 0
  11.  
  12. # a must consist of 16 three-bit chunks (leftmost must be non-zero)
  13. # otherwise output will be wrong length
  14.  
  15. # only the rightmost ten bits of a can affect the result of the current loop iteration
  16.  
  17. target = [2,4,REDACTED,7,5,REDACTED,5,5,0,3,3,0]
  18. a_chunk_lists = []
  19.  
  20. for pointer in range(16):
  21.   a_chunk_list = []
  22.   cap = 1024
  23.   if pointer == 15:
  24.     cap = 8
  25.   if pointer == 14:
  26.     cap = 64
  27.   if pointer == 13:
  28.     cap = 512
  29.   for a_chunk in range(cap):
  30.     b = a_chunk % 8
  31.     REDACTED
  32.     c = int(a_chunk / (2 ** b))
  33.     REDACTED
  34.     REDACTED
  35.     if b % 8 == target[pointer]:
  36.       a_chunk_list.append(a_chunk)
  37.   a_chunk_lists.append(a_chunk_list)
  38.  
  39. # each 10-bit chunk after the first has 7 bits overlapping with previous
  40.  
  41. def chunk_as_binary(a_chunk):
  42.   return bin(1024 + a_chunk)[3:] # "0b1##########" -> "##########"
  43.  
  44. def look_for_valid_combo(position, list):
  45.   previous_binary = chunk_as_binary(list[-1])
  46.   for a_chunk in a_chunk_lists[position]:
  47.     a_binary = chunk_as_binary(a_chunk)
  48.     if a_binary[:7] != previous_binary[3:]:
  49.       continue
  50.     new_list = list.copy()
  51.     new_list.append(a_chunk)
  52.     if position == 0:
  53.       a = 0
  54.       for position in range(16):
  55.         a = 8 * a + (new_list[position] % 8)
  56.       print (a)
  57.       sys.exit()
  58.     look_for_valid_combo(position - 1, new_list)
  59.  
  60. for a_chunk in a_chunk_lists[15]:
  61.   look_for_valid_combo(14, [a_chunk])
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement