Skip to content

Instantly share code, notes, and snippets.

@Klice
Created December 11, 2023 07:14
Show Gist options
  • Save Klice/c7237c3f1abace85e03b3a2d48418e5f to your computer and use it in GitHub Desktop.
Save Klice/c7237c3f1abace85e03b3a2d48418e5f to your computer and use it in GitHub Desktop.
fastest $3B in GTA5
import math
from datetime import timedelta
GOAL = 1000000000
STOCK_BUY_TIME = 10
GLITCH_TIME = 15 * 60
DIVE_TIME = 53
CASE_MONEY = 25000
def do_glitch_and_buy_n_times(time, money, n):
time = do_glitch(time)
time, money, times = do_buy_stocks(time, money, n)
return time, money, times
def find_best_n(start_time, start_money, num_glitches):
n = 1
n2 = 1
min_time = 0
min_money = 0
min_n = 0
min_n2 = 0
if num_glitches == 0:
return do_glitch_and_buy_n_times(start_time, start_money, None)
while True:
time = start_time
money = start_money
time, money, _ = do_glitch_and_buy_n_times(time, money, n)
if money >= GOAL:
break
if num_glitches > 1:
time, money, n2 = find_best_n(time, money, num_glitches-1)
else:
time, money, n2 = do_glitch_and_buy_n_times(time, money, None)
if time < min_time or min_time == 0:
min_time = time
min_money = money
min_n = n
if isinstance(n2, list):
min_n2 = n2
else:
min_n2 = [n2]
n += 1
return min_time, min_money, [min_n] + min_n2
def do_buy_stocks(time, money, times=None):
if times is None:
times = math.ceil((GOAL - money) / money)+1
return (time + STOCK_BUY_TIME * times, money * times, times)
def do_glitch(time):
return time + GLITCH_TIME
res = []
for d in range(1, 100):
print(f"--> Dives {d} Money {CASE_MONEY * d}")
for g in range(6):
t, m, n = find_best_n(DIVE_TIME * d, CASE_MONEY * d, g)
tt = "{:0>8}".format(str(timedelta(seconds=t)))
r = f"Time {tt}, Start Money {d * CASE_MONEY}, N {n}"
print(r)
res.append((t, r))
print("======================")
for t, r in sorted(res, key=lambda tup: tup[0]):
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment