Last active
March 1, 2022 00:11
-
-
Save maxfire2008/fed24073b14f4ad6fa3c9864442c722c to your computer and use it in GitHub Desktop.
Brute force a conversion formula for page numbers between 2 editions of a book
This file contains 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
mapping = [ | |
["Spring 1941",40,38], | |
["Part 3",54,53], | |
["My day",44,43], | |
["Fall 1941",50,49], | |
["Bombs!",176,192], | |
] | |
def difference(a,b): | |
if a > b: | |
return a-b | |
elif b > a: | |
return b-a | |
return 0 | |
def test(calc,verbose=True): | |
total_error = 0 | |
if verbose: | |
print("Name,Grey Book,Yellow Guessed,Yellow Actual,Error") | |
for name,grey,yellow in mapping: | |
calc_y = eval(calc.replace("g",str(grey))) | |
total_error+=difference(calc_y,yellow) | |
if verbose: | |
print(name,grey,calc_y,yellow,calc_y-yellow) | |
return total_error | |
tests = [] | |
for a in range(113800,114000): | |
if a % 100: | |
print(a) | |
a/=100000 | |
for b in range(-85000,-84500): | |
b/=10000 | |
tests.append([test(f"(g*{a})+{b}",verbose=False),f"(g*{a})+{b}"]) | |
tests.sort() | |
#2.7575000000000216, (g*1.1388)+-8.4301 | |
#1.9988799999999713, (g*1.13602)-7.94 | |
#1.8599200000000025, (g*1.13602)-7.8 | |
#1.858920000000026, (g*1.13602)-7.801 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment