Created
February 18, 2025 04:01
-
-
Save phoeagon/3004e81f60188dd7a09918b69412703a to your computer and use it in GitHub Desktop.
Solver for number towers for "YEAH! YOU WANT "THOSE GAMES," RIGHT? SO HERE YOU GO! NOW, LET'S SEE YOU CLEAR THEM!"
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 itertools import permutations | |
def ev(start, it): | |
x = start | |
for i in it: | |
if i[0] in ('/', '*', '-', '+'): | |
y = int(i[1:]) | |
x = int(eval(str(x) + i)) | |
if x < 0: | |
x = -100000 | |
else: | |
y = int(i) | |
x = x + y if x > y else -100000 | |
return x | |
start = int(input('input starting int\n')) | |
while True: | |
ops = input('input all var\n').replace('x','*') | |
inputs = ops.split(' ') | |
maxv = -1 | |
max_iter = None | |
for it in permutations(inputs): | |
v = ev(start, it) | |
if v > maxv: | |
maxv, max_iter = v, it | |
print("maxv = " , maxv ) | |
print(max_iter ) | |
start = maxv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment