diff options
author | Emile <git@emile.space> | 2023-02-19 17:22:24 +0100 |
---|---|---|
committer | Emile <git@emile.space> | 2023-02-19 17:22:24 +0100 |
commit | 3c231ddc25879929e0532811b14a01d5c9af44d8 (patch) | |
tree | 11d367c85feab12788d7ec701734df9afee7e64c | |
parent | 24afd4d2e108937feb1cef343f5429b8f773efc2 (diff) |
limit amount of tests to 100_000 and add CTRL-C handling
-rw-r--r-- | solve.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/solve.py b/solve.py index 6ec7ff3..2cef7ed 100644 --- a/solve.py +++ b/solve.py @@ -455,6 +455,10 @@ def brute_force(level, s, t, goal_s, goal_t): counter += CHUNK_SIZE + # set a limit for the amount of tries we're doing + if counter == 100_000: + return [] + return rands def brute_force_single(level, s, goal_s): @@ -635,6 +639,9 @@ while True: # solve manually else: res = brute_force(level, s, t, goal_s, goal_t) + if res == []: + print("could not find solution in given amount of tries, skipping") + continue print("SOLVE MANUALLY") print(res) @@ -657,6 +664,16 @@ while True: #p.interactive() level += 1 + + # catch CTRL-C for skipping the current testcase, there's a 3 second window + # for pressing CTRL-C again for completely stopping the script + except KeyboardInterrupt: + try: + time.sleep(3) + continue + except KeyboardInterrupt: + exit() + except: print("SOMETHING WENT HORRIBLY WRONG!") |