u/Desperate-Mud-1459

I made a script to simulate dougdoug's 10 minute timer in his latest video

After 250000 simulations, I found that the average time the 10 minute timer took to finish was 237,545,427,080,684.16 real-world seconds, which is equivalent to 7,527,514 years.

Some other statistics:

Median Time: 1,846.97 seconds

Shortest Run: 2.00 seconds

Longest Run: 106,691,973,808,757,744.00 real world seconds, which is 3,380,934,058 years (approximately a quarter of the age of the universe)

The reason why the average time is so much larger than the median is because of extreme "unlucky" cases where the timer or the time it takes for the timer to tick repeatedly doubles which is also why the longest run is so long

Anyways I am not sure if the script is actually correct but you can try it yourself below (disclaimer: I myself did not write the script I just prompted an ai):

import random
import time
import statistics


def run_simulation(max_wall_time, global_start_time):
    timer_time = 10 * 60  # Starts at 10 minutes (600 seconds)
    real_time = 0.0
    tick_length = 1.0  # Tracks real-world seconds per timer second
    steps = 0

    while timer_time > 0:
        # Safety kill-switch for the wall-clock (checks every 10k steps)
        if steps % 10000 == 0:
            if time.time() - global_start_time > max_wall_time:
                return None
        steps += 1

        r = random.random()

        if r < 0.05:
            # 5% chance: add 1 second
            timer_time += 1
            real_time += tick_length
        elif r < 0.06:
            # 1% chance: add 1 minute
            timer_time += 60
            real_time += tick_length
        elif r < 0.07:
            # 1% chance: remove 1 minute
            timer_time -= 60
            real_time += tick_length
        elif r < 0.12:
            # 5% chance: freezes for 5 timer-seconds
            real_time += 5.0 * tick_length
        elif r < 0.13:
            # 1% chance: doubles the amount of time left
            timer_time *= 2
            real_time += tick_length
        elif r < 0.14:
            # 1% chance: halves the amount of time left
            timer_time //= 2
            real_time += tick_length
        elif r < 0.15:
            # 1% chance: seconds and minutes swap (discarding hours)
            m = (timer_time % 3600) // 60
            s = timer_time % 60
            timer_time = s * 60 + m
            real_time += tick_length
        elif r < 0.16:
            # 1% chance: round to the nearest minute up or down
            m = timer_time // 60
            s = timer_time % 60
            if s >= 30:
                timer_time = (m + 1) * 60
            else:
                timer_time = m * 60
            real_time += tick_length
        elif r < 0.17:
            # 1% chance: timer ticks twice as fast (tick length halves)
            tick_length /= 2.0
            timer_time -= 1
            real_time += tick_length
        elif r < 0.18:
            # 1% chance: timer ticks twice as long (tick length doubles)
            tick_length *= 2.0
            timer_time -= 1
            real_time += tick_length
        else:
            # 82% chance: timer decreases normally
            timer_time -= 1
            real_time += tick_length

        if timer_time < 0:
            timer_time = 0

    return real_time


def main():
    TARGET_SIMULATIONS = 250000
    MAX_WALL_TIME = 10 * 60  # 10 minutes max real-time processing limit

    global_start_time = time.time()
    results = []

    print(f"Starting simulation run... (Target: {TARGET_SIMULATIONS:,} simulations)")
    print(f"Script will automatically terminate after 10 minutes.")
    print("-" * 50)

    for i in range(TARGET_SIMULATIONS):
        if time.time() - global_start_time > MAX_WALL_TIME:
            print("\n[!] 10-Minute Timeout Reached! Stopping early.")
            break

        sim_result = run_simulation(MAX_WALL_TIME, global_start_time)

        if sim_result is None:
            print("\n[!] 10-Minute Timeout Reached inside a simulation loop! Stopping early.")
            break

        results.append(sim_result)

        if (i + 1) % 25000 == 0:
            elapsed = time.time() - global_start_time
            print(f"Completed {i + 1:,} / {TARGET_SIMULATIONS:,} simulations... (Elapsed: {elapsed:.2f}s)")

    if len(results) > 0:
        expected_value = statistics.mean(results)
        median_value = statistics.median(results)
        max_value = max(results)
        min_value = min(results)

        print("\n" + "=" * 50)
        print("SIMULATION RESULTS")
        print("=" * 50)
        print(f"Total Simulations Run : {len(results):,}")
        print(f"Expected Value (Mean) : {expected_value:,.2f} real-world seconds")
        print(f"Median Time           : {median_value:,.2f} seconds")
        print(f"Shortest Run          : {min_value:,.2f} seconds")
        print(f"Longest Run           : {max_value:,.2f} seconds")
    else:
        print("No simulations completed in time.")


if __name__ == "__main__":
    main()import random
import time
import statistics


def run_simulation(max_wall_time, global_start_time):
    timer_time = 10 * 60  # Starts at 10 minutes (600 seconds)
    real_time = 0.0
    tick_length = 1.0  # Tracks real-world seconds per timer second
    steps = 0

    while timer_time > 0:
        # Safety kill-switch for the wall-clock (checks every 10k steps)
        if steps % 10000 == 0:
            if time.time() - global_start_time > max_wall_time:
                return None
        steps += 1

        r = random.random()

        if r < 0.05:
            # 5% chance: add 1 second
            timer_time += 1
            real_time += tick_length
        elif r < 0.06:
            # 1% chance: add 1 minute
            timer_time += 60
            real_time += tick_length
        elif r < 0.07:
            # 1% chance: remove 1 minute
            timer_time -= 60
            real_time += tick_length
        elif r < 0.12:
            # 5% chance: freezes for 5 timer-seconds
            real_time += 5.0 * tick_length
        elif r < 0.13:
            # 1% chance: doubles the amount of time left
            timer_time *= 2
            real_time += tick_length
        elif r < 0.14:
            # 1% chance: halves the amount of time left
            timer_time //= 2
            real_time += tick_length
        elif r < 0.15:
            # 1% chance: seconds and minutes swap (discarding hours)
            m = (timer_time % 3600) // 60
            s = timer_time % 60
            timer_time = s * 60 + m
            real_time += tick_length
        elif r < 0.16:
            # 1% chance: round to the nearest minute up or down
            m = timer_time // 60
            s = timer_time % 60
            if s >= 30:
                timer_time = (m + 1) * 60
            else:
                timer_time = m * 60
            real_time += tick_length
        elif r < 0.17:
            # 1% chance: timer ticks twice as fast (tick length halves)
            tick_length /= 2.0
            timer_time -= 1
            real_time += tick_length
        elif r < 0.18:
            # 1% chance: timer ticks twice as long (tick length doubles)
            tick_length *= 2.0
            timer_time -= 1
            real_time += tick_length
        else:
            # 82% chance: timer decreases normally
            timer_time -= 1
            real_time += tick_length

        if timer_time < 0:
            timer_time = 0

    return real_time


def main():
    TARGET_SIMULATIONS = 250000
    MAX_WALL_TIME = 10 * 60  # 10 minutes max real-time processing limit

    global_start_time = time.time()
    results = []

    print(f"Starting simulation run... (Target: {TARGET_SIMULATIONS:,} simulations)")
    print(f"Script will automatically terminate after 10 minutes.")
    print("-" * 50)

    for i in range(TARGET_SIMULATIONS):
        if time.time() - global_start_time > MAX_WALL_TIME:
            print("\n[!] 10-Minute Timeout Reached! Stopping early.")
            break

        sim_result = run_simulation(MAX_WALL_TIME, global_start_time)

        if sim_result is None:
            print("\n[!] 10-Minute Timeout Reached inside a simulation loop! Stopping early.")
            break

        results.append(sim_result)

        if (i + 1) % 25000 == 0:
            elapsed = time.time() - global_start_time
            print(f"Completed {i + 1:,} / {TARGET_SIMULATIONS:,} simulations... (Elapsed: {elapsed:.2f}s)")

    if len(results) > 0:
        expected_value = statistics.mean(results)
        median_value = statistics.median(results)
        max_value = max(results)
        min_value = min(results)

        print("\n" + "=" * 50)
        print("SIMULATION RESULTS")
        print("=" * 50)
        print(f"Total Simulations Run : {len(results):,}")
        print(f"Expected Value (Mean) : {expected_value:,.2f} real-world seconds")
        print(f"Median Time           : {median_value:,.2f} seconds")
        print(f"Shortest Run          : {min_value:,.2f} seconds")
        print(f"Longest Run           : {max_value:,.2f} seconds")
    else:
        print("No simulations completed in time.")


if __name__ == "__main__":
    main()
reddit.com
u/Desperate-Mud-1459 — 3 days ago