Created
March 8, 2025 23:58
-
-
Save xssfox/65564c40dacd9d319b8064f9d64de88f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from decimal import Decimal, getcontext | |
from math import floor | |
import bitarray | |
import pytesseract | |
getcontext().prec = 10000 | |
def isOdd(i): | |
image = b'' | |
for y in range (0,17): | |
row = bitarray.bitarray() | |
for x in range (0,106): | |
pixel = (0.5 < floor((Decimal(((i//2*2)//i* | |
492732544050369542344248234069770036904790181552694170181527120276862108210933015675233753839729812079158305435106285932324536306945493088812156157820992773400259409328734208 | |
+(1-(i//2*2)//i)* | |
53494312310508070110850614959687875662646679323315568340205808089169687507732526715216084001336313934389357029685736158572734945155756251525123407872 | |
)+y) // 17 * (2 ** (Decimal(-17 * x - (((i//2*2)//i* | |
492732544050369542344248234069770036904790181552694170181527120276862108210933015675233753839729812079158305435106285932324536306945493088812156157820992773400259409328734208 | |
+(1-(i//2*2)//i)* | |
53494312310508070110850614959687875662646679323315568340205808089169687507732526715216084001336313934389357029685736158572734945155756251525123407872 | |
)-y) % 17)))) % 2)) | |
if pixel: | |
row.append(0) | |
else: | |
row.append(1) | |
image = image + row.tobytes() | |
im = Image.frombytes("1",[106,17],image) | |
result = pytesseract.image_to_string(im).strip() | |
if result == "Odd": | |
return True | |
elif result == "Even": | |
return False | |
else: | |
raise ValueError('Not sure.') | |
print(isOdd(2)) | |
print(isOdd(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment