not completley

what i want, but a good start, now its possible to use tha math tools on the binary line, if its not doing something unexpectedxx

no, it doesnt, the input is wrong, its using the binary of the names instead of the file binatys , was worth a trytho

https://chat.openai.com/share/d328704e-2535-462d-baf0-ab0ca7845fee

The code does the following in simpler terms:

  1. Turns Names into Numbers: It changes script names like “cat” or “ls” into numbers, making them easier to work with.
  2. Predicts Future Numbers: Based on the pattern of the numbers, it guesses what the next few numbers could be.
  3. Shows Predictions as Numbers and Lines: It draws a dark-themed chart showing both the original numbers and the guessed future numbers.
  4. Saves the Chart: Finally, it saves this chart as an image file so you can see it anytime.

(new_venv) [lia@share ~]$ python3 grpx
python3 grpx
Original Program Name, Binary Number, Number Line Position:
ls, 0110110001110011, 27763.0
cat, 011000110110000101110100, 6513012.0
pwd, 011100000111011101100100, 7370596.0
echo, 01100101011000110110100001101111, 1701013615.0
grep, 01100111011100100110010101110000, 1735550320.0

Predicted Number Line Positions (Decimal and Binary):
Decimal: 2169430959.25, Binary: 10000001010011101110001110101111
Decimal: 2603311598.5, Binary: 10011011001010110110000111101110
Decimal: 3037192237.75, Binary: 10110101000001111110000000101101
Decimal: 3471072877.0, Binary: 11001110111001000101111001101101
Decimal: 3904953516.25, Binary: 11101000110000001101110010101100
/home/lia/grpx:78: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
(new_venv) [lia@share ~]$ ^C

import matplotlib.pyplot as plt

def name_to_binary(name):
    """Convert a script name to its binary representation."""
    return ''.join(format(ord(c), '08b') for c in name)

def binary_to_decimal(binary_str):
    """Convert a binary string to a decimal (float) value."""
    return float(int(binary_str, 2))

def decimal_to_binary(decimal):
    """Convert a decimal (float) value to a binary string."""
    return format(int(decimal), 'b')

def linear_extrapolation(data_points, num_predictions=3):
    """Predict future values using linear extrapolation based on existing data points."""
    if len(data_points) < 2:
        raise ValueError("Need at least two data points for linear extrapolation.")
    steps = [data_points[i] - data_points[i-1] for i in range(1, len(data_points))]
    average_step = sum(steps) / len(steps)
    last_point = data_points[-1]
    predictions = [last_point + (i + 1) * average_step for i in range(num_predictions)]
    return predictions

# List of common script names
script_names = ["cat", "ls", "echo", "pwd", "grep"]

# Convert names to binary and map to decimal
mapped_values = []
name_binary_decimal_map = []  # Store tuples of (name, binary, decimal)
for name in script_names:
    binary_rep = name_to_binary(name)
    decimal_pos = binary_to_decimal(binary_rep)
    mapped_values.append(decimal_pos)
    name_binary_decimal_map.append((name, binary_rep, decimal_pos))

# Sort by decimal position
mapped_values.sort()
name_binary_decimal_map.sort(key=lambda x: x[2])  # Sort the mapping list by decimal values

# Echo the original program name, binary number, and number line position
print("Original Program Name, Binary Number, Number Line Position:")
for name, binary, decimal in name_binary_decimal_map:
    print(f"{name}, {binary}, {decimal}")

# Predict new number line positions
predicted_positions = linear_extrapolation(mapped_values, 5)

# Output the predictions in decimal and binary
print("\nPredicted Number Line Positions (Decimal and Binary):")
for position in predicted_positions:
    binary_rep = decimal_to_binary(position)
    print(f"Decimal: {position}, Binary: {binary_rep}")

# Prepare data for plotting
original_positions = range(1, len(mapped_values) + 1)  # Original positions for x-axis
predicted_positions_x = range(len(mapped_values) + 1, len(mapped_values) + 1 + len(predicted_positions))

# Setting the style to dark mode
plt.style.use('dark_background')

# Plotting original decimal values
plt.plot(original_positions, mapped_values, 'ro-', label='Original Values')

# Plotting predicted values
plt.plot(predicted_positions_x, predicted_positions, 'bo--', label='Predicted Values')

# Adding titles and labels
plt.title('Script Name Positions and Predictions')
plt.xlabel('Position')
plt.ylabel('Decimal Value')
plt.legend()

# Save the graph
plt.savefig('/mnt/data/script_positions_predictions_darkmode.png', dpi=300)

# Show the plot
plt.show()

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *