Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- # 2,4 b = a % 8
- # REDACTED: twiddle B
- # 7,5 c = a / (2^b)
- # REDACTED: twiddle B
- # REDACTED: twiddle B
- # 5,5 output b % 8
- # 0,3 a = a / 8
- # 3,0 if a != 0 then jump to 0
- # a must consist of 16 three-bit chunks (leftmost must be non-zero)
- # otherwise output will be wrong length
- # only the rightmost ten bits of a can affect the result of the current loop iteration
- target = [2,4,REDACTED,7,5,REDACTED,5,5,0,3,3,0]
- a_chunk_lists = []
- for pointer in range(16):
- a_chunk_list = []
- cap = 1024
- if pointer == 15:
- cap = 8
- if pointer == 14:
- cap = 64
- if pointer == 13:
- cap = 512
- for a_chunk in range(cap):
- b = a_chunk % 8
- REDACTED
- c = int(a_chunk / (2 ** b))
- REDACTED
- REDACTED
- if b % 8 == target[pointer]:
- a_chunk_list.append(a_chunk)
- a_chunk_lists.append(a_chunk_list)
- # each 10-bit chunk after the first has 7 bits overlapping with previous
- def chunk_as_binary(a_chunk):
- return bin(1024 + a_chunk)[3:] # "0b1##########" -> "##########"
- def look_for_valid_combo(position, list):
- previous_binary = chunk_as_binary(list[-1])
- for a_chunk in a_chunk_lists[position]:
- a_binary = chunk_as_binary(a_chunk)
- if a_binary[:7] != previous_binary[3:]:
- continue
- new_list = list.copy()
- new_list.append(a_chunk)
- if position == 0:
- a = 0
- for position in range(16):
- a = 8 * a + (new_list[position] % 8)
- print (a)
- sys.exit()
- look_for_valid_combo(position - 1, new_list)
- for a_chunk in a_chunk_lists[15]:
- look_for_valid_combo(14, [a_chunk])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement