fixed #2, fixed #8

This commit is contained in:
2020-01-12 10:49:55 +01:00
parent 3e999e679e
commit 9238db3134
2 changed files with 16 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
# (c) 2020 Simon Averbach and Zev Averbach
from time import sleep
from config import MAX_NUM, DEFAULT_COUNTING_SPEED
from config import MAX_NUM, DEFAULT_COUNTING_SPEED, MAX_RUNNING_TIME_SECONDS
def math_game():
@@ -24,6 +24,20 @@ def math_game():
else:
num_counts_per_second = int(num_counts_per_second_string)
predicted_running_time_seconds = int((number / each) / num_counts_per_second)
while predicted_running_time_seconds > MAX_RUNNING_TIME_SECONDS:
print(f"Sorry, that would run for {predicted_running_time_seconds:,} seconds, which is greater than "
f"the maximum allowed of {MAX_RUNNING_TIME_SECONDS:,} seconds.")
suggested_num_counts_per_second = int((number / each) / MAX_RUNNING_TIME_SECONDS)
print(f"I suggest you run a minimum of {suggested_num_counts_per_second:,} counts per second.")
print(f"How many counts do you want to do per second? [{suggested_num_counts_per_second:,}]")
num_counts_per_second_string = input("> ")
if num_counts_per_second_string == '':
num_counts_per_second = suggested_num_counts_per_second
else:
num_counts_per_second = int(num_counts_per_second_string)
predicted_running_time_seconds = (number / each) / num_counts_per_second
print(f"Okay, here we go! We're going to count from zero to {number}, "
f"adding {each} {num_counts_per_second} times per second.")
sleep(3)