OPEN 28/6



0by 0x tinyZED imageTEXT theTUBE

- conservation of creation -

zett

import random

def read_binary_file_as_bits(file_path):
    with open(file_path, 'rb') as file:
        binary_data = file.read()

    # Convert binary data to a list of truth values
    truth_values = []
    for byte in binary_data:
        for bit in range(8):
            truth_values.append((byte & (1 << bit)) != 0)
    
    return truth_values


def calculate_runs(truth_values):
    runs = []
    current_run_length = 1  # Initialize to 1 as the shortest possible run is 1

    for value in truth_values:
        if value:  # True
            runs.append(current_run_length)
            current_run_length = 1  # Reset to 1 for the next run
        else:  # False
            current_run_length += 1

    return runs

def replace_first_pair_of_runs(runs):
    if len(runs) >= 3:
        run1 = runs[0]
        run2 = runs[1]
        run3 = runs[2]
        if run1 == run2 == 1:
            runs.pop(0)
            runs[0] = 1
        else:
            t = run1 + run2 - 1
            run2 = run1
            run1 = t
            if run1 == run2:
                runs.pop(0)
                runs[0] = run1
                runs[1] = run2 + run3 - 1
            else:
                runs[0] = run1
                runs[1] = run2
           
    
    return runs

def true_false_sequence(numbers):
    result = []
    for n in numbers:
        if n > 0:  # Ensure n is a positive integer
            result.extend([True] * (n - 1) + [False])
    return result


def xor_truth_values(current_seed, truth_values):
    # Initialize the random number generator
    random.seed(current_seed)
    
    xor_result = 0
    for i in range(42):
        # Generate a pseudorandom truth value (True or False)
        random_value = random.choice([True, False])
        # XOR the input truth value with the pseudorandom truth value
        xor_result = truth_values[i] ^ random_value
        truth_values[i] = xor_result
    return truth_values

def process_runs(current_seed, file_path, num_iterations):
    truth_values = read_binary_file_as_bits(file_path)

    for _ in range(num_iterations):
        runs = calculate_runs(truth_values)
        runs = replace_first_pair_of_runs(runs)
        truth_values = true_false_sequence(runs)
        truth_values = xor_truth_values(current_seed, truth_values)
        current_seed += 31515433


    return truth_values

# Example usage
current_seed = 6633442536
file_path = '/storage/emulated/0/qpython/core.py'
num_iterations = 13500
final_bits = process_runs(current_seed, file_path, num_iterations)
for i in final_bits:
    if i:
        print(1, end='')
    else: 
        print(0)
print()
print(len(final_bits))