Advertisement
markruff

Turing Complete - Binary Racer

Oct 5th, 2024
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import keyboard
  2. import time
  3.  
  4. while True:
  5.     i = int(input("Enter a number (0-255): "))
  6.     time.sleep(0.2)
  7.     keyboard.send("alt+tab") # into Turing Complete
  8.     time.sleep(0.2)
  9.  
  10.     x = 128  # Start with the highest bit in a byte (2^7)
  11.    
  12.     while x > 0:
  13.         if i >= x:  # Check if the current bit is "on"
  14.             print(x, end=' ')  # This is the power of 2 that is "on"
  15.             keyboard.send(str(8 - (x.bit_length() - 1)))  # Keypress: 1 = 128, 2 = 64 etc
  16.             i -= x  # Subtract the value of the bit
  17.         x = x // 2  # Move to the next lower bit
  18.     print()
  19.     keyboard.send("space")
  20.     keyboard.send("alt+tab") # back to Python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement