LimePaste888

Addition Pacer Test (11~99 no 10-multiple)

May 31st, 2025 (edited)
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.77 KB | Gaming | 0 0
  1. import time, random#, math
  2. version = "sum"
  3.  
  4. def generateNumber():
  5.     return random.randint(1, 9)*10 + random.randint(1, 9)
  6. def timeFromQuestion(q=0):
  7.     if q < 50:
  8.         return 20 - (q%5)/8 - q//5
  9.     elif q < 82:
  10.         return 16.25 - q/8
  11.     else:
  12.         return 8.5625 - q/32
  13. def resultsFailDisplay(fail):
  14.     if not fail:
  15.         return 'Undocumented'
  16.     concats = []
  17.     if fail['incorrect']:
  18.         user = fail['question'][3]
  19.         try:
  20.             useri = int(user)
  21.             if user == useri:
  22.                 user = useri
  23.         except:
  24.             pass
  25.         toappend = f"incorrect ({fail['question'][0]} + {fail['question'][1]} = {fail['question'][2]}"
  26.         if user:
  27.             toappend += ' ≠ '+str(user)+')'
  28.         else:
  29.             toappend += ", didn't answer)"
  30.         concats.append(toappend)
  31.     if fail['timedout']:
  32.         concats.append(f"timed out ({'{:.3f}'.format(fail['timetaken'])} > {fail['limit']})")
  33.     if len(concats):
  34.         return ', '.join(concats).capitalize()
  35.     else:
  36.         return 'Reason not given'
  37.  
  38. defaultlives = 4
  39. startlives = None
  40. lives = None
  41. question = 0
  42. timedoutcount = 0
  43. correctcount = 0
  44. totaltimec = 0.0
  45. totaltimea = 0.0
  46. totallimits = 0.0
  47. fails = []
  48. times = []
  49.  
  50. print(f'Welcome to the Addition Pacer Test. This version is {version}.')
  51. tutorial = input('Would you like to be introduced? (y/n) ')
  52. if tutorial:
  53.     tutorial = tutorial[0].lower() == 'y'
  54. if tutorial:
  55.     print('''=== ADDITION PACER ===
  56. The Addition Pacer Test is a multistage addition speed test that progressively gets more difficult as it continues.
  57. The 11~99 no 10-multiple pacer test will begin 3 seconds after you press the Enter key while Shift is not held.
  58. Get a notepad ready.
  59. The time limit starts high, but gets faster each question, and also every 5 questions until question 50.
  60. Every time the latter happens, you should see this:
  61. == LEVEL n ==
  62. At 20 questions and 50 questions, you will receive a break for as long as you desire, which ends 3 seconds after you press the Enter key while the Shift key is not held.
  63. Remember to make as little mistakes as possible, and add for as long as possible.
  64. The fourth time you fail to add correctly in time, your test is over.''')
  65. while startlives == None:
  66.     try:
  67.         user = input(f'Set lives (leave blank for default ({defaultlives})): ')
  68.         if user:
  69.             startlives = int(user)
  70.             if startlives <= 0:
  71.                 print('Must be greater than 0.')
  72.                 startlives = None
  73.         else:
  74.             startlives = 4
  75.     except:
  76.         print('Invalid integer.')
  77. lives = startlives
  78. print('The test will begin on the word "start" 3 seconds after you press the Enter key while the Shift key is not held.')
  79. input('> ')
  80. time.sleep(1)
  81. print('On your marks,')
  82. time.sleep(1)
  83. print('get set,')
  84. time.sleep(1)
  85. print('start.\n')
  86. while True:
  87.     if lives <= 0:
  88.         break
  89.     if question == 50:
  90.         print('== q50: CHALLENGE LEVEL ==')
  91.     elif question%5 == 0:
  92.         if question < 50:
  93.             print(f'== q{question}: LEVEL {question//5} ==')
  94.         else:
  95.             print(f'== q{question} ==')
  96.     elif question == 82:
  97.         print('== q82: MASTER LEVEL ==')
  98.     if question in [20,50]:
  99.         print(f'Your question {question} break has started.')
  100.         if question == 50:
  101.             print('''The next questions will not get faster every 5 questions, but will still get faster every question.
  102. The time limit decrease will slow to 1/32 s per question at question 82 (6s limit). Good luck.''')
  103.         input('''When you're ready to continue, press the Enter key while not holding the Shift key.
  104. The test will continue on the word "continue" 3 seconds after.
  105. > ''')
  106.         time.sleep(1)
  107.         print('On your marks,')
  108.         time.sleep(1)
  109.         print('get set,')
  110.         time.sleep(1)
  111.         print('continue.')
  112.     x = generateNumber()
  113.     y = generateNumber()
  114.     ans = x + y
  115.     start = time.time()
  116.     limit = timeFromQuestion(question)
  117.     totallimits += limit
  118.     user = input(f'{limit}s: {x} + {y} = ')[:64]
  119.     correct = False
  120.     try:
  121.         user = float(user)
  122.         correct = user == ans
  123.     except:
  124.         pass
  125.     timetaken = time.time() - start
  126.     totaltimea += timetaken
  127.     print(f'''{'{:.3f}'.format(timetaken)}s; {'{:.3f}'.format(limit - timetaken)}s left''')
  128.     timedout = timetaken > limit
  129.     if correct:
  130.         correctcount += 1
  131.         totaltimec += timetaken
  132.     else:
  133.         lives -= 1
  134.         print(f'Not correct ({ans}).')
  135.     if timedout:
  136.         print('Ran out of time.')
  137.         if correct:
  138.             lives -= 1
  139.         timedoutcount += 1
  140.     if timedout or not correct:
  141.         print(f"{lives} {'life' if lives == 1 else 'lives'} left.")
  142.         fails.append({
  143.             'n': question,
  144.             'incorrect': not correct,
  145.             'question': [x, y, ans, user],
  146.             'timedout': timedout,
  147.             'timetaken': timetaken,
  148.             'limit': limit
  149.         })
  150.     question += 1
  151. input(f"""The test has ended.
  152.  
  153. === RESULTS (using {startlives} lives) ===
  154. Version: {version}
  155. Questions reached: {question} (q{question-1})
  156. (press enter without shift to continue)""")
  157. print(f"""Questions correct: {correctcount}
  158. Questions incorrect: {question - correctcount}
  159. Accuracy: {'{:.3f}'.format(correctcount / question * 100)}%""")
  160. if correctcount:
  161.     print(f"Average time taken (correct): {'{:.3f}'.format(totaltimec / correctcount)}s")
  162. print(f"Average time taken: {'{:.3f}'.format(totaltimea / question)}s")
  163. print(f"Total time taken: {'{:.3f}'.format(totaltimea)}s")
  164. print("== Fail reasons ==")
  165. for i in range(len(fails)):
  166.     fail = fails[i]
  167.     print(f'Fail #{i+1} @ q{fail["n"]}: {resultsFailDisplay(fail)}')
  168. input('\nPress Enter without Shift to exit > ')
  169.  
Advertisement
Add Comment
Please, Sign In to add comment