Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, random#, math
- version = "sum"
- def generateNumber():
- return random.randint(1, 9)*10 + random.randint(1, 9)
- def timeFromQuestion(q=0):
- if q < 50:
- return 20 - (q%5)/8 - q//5
- elif q < 82:
- return 16.25 - q/8
- else:
- return 8.5625 - q/32
- def resultsFailDisplay(fail):
- if not fail:
- return 'Undocumented'
- concats = []
- if fail['incorrect']:
- user = fail['question'][3]
- try:
- useri = int(user)
- if user == useri:
- user = useri
- except:
- pass
- toappend = f"incorrect ({fail['question'][0]} + {fail['question'][1]} = {fail['question'][2]}"
- if user:
- toappend += ' ≠ '+str(user)+')'
- else:
- toappend += ", didn't answer)"
- concats.append(toappend)
- if fail['timedout']:
- concats.append(f"timed out ({'{:.3f}'.format(fail['timetaken'])} > {fail['limit']})")
- if len(concats):
- return ', '.join(concats).capitalize()
- else:
- return 'Reason not given'
- defaultlives = 4
- startlives = None
- lives = None
- question = 0
- timedoutcount = 0
- correctcount = 0
- totaltimec = 0.0
- totaltimea = 0.0
- totallimits = 0.0
- fails = []
- times = []
- print(f'Welcome to the Addition Pacer Test. This version is {version}.')
- tutorial = input('Would you like to be introduced? (y/n) ')
- if tutorial:
- tutorial = tutorial[0].lower() == 'y'
- if tutorial:
- print('''=== ADDITION PACER ===
- The Addition Pacer Test is a multistage addition speed test that progressively gets more difficult as it continues.
- The 11~99 no 10-multiple pacer test will begin 3 seconds after you press the Enter key while Shift is not held.
- Get a notepad ready.
- The time limit starts high, but gets faster each question, and also every 5 questions until question 50.
- Every time the latter happens, you should see this:
- == LEVEL n ==
- 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.
- Remember to make as little mistakes as possible, and add for as long as possible.
- The fourth time you fail to add correctly in time, your test is over.''')
- while startlives == None:
- try:
- user = input(f'Set lives (leave blank for default ({defaultlives})): ')
- if user:
- startlives = int(user)
- if startlives <= 0:
- print('Must be greater than 0.')
- startlives = None
- else:
- startlives = 4
- except:
- print('Invalid integer.')
- lives = startlives
- print('The test will begin on the word "start" 3 seconds after you press the Enter key while the Shift key is not held.')
- input('> ')
- time.sleep(1)
- print('On your marks,')
- time.sleep(1)
- print('get set,')
- time.sleep(1)
- print('start.\n')
- while True:
- if lives <= 0:
- break
- if question == 50:
- print('== q50: CHALLENGE LEVEL ==')
- elif question%5 == 0:
- if question < 50:
- print(f'== q{question}: LEVEL {question//5} ==')
- else:
- print(f'== q{question} ==')
- elif question == 82:
- print('== q82: MASTER LEVEL ==')
- if question in [20,50]:
- print(f'Your question {question} break has started.')
- if question == 50:
- print('''The next questions will not get faster every 5 questions, but will still get faster every question.
- The time limit decrease will slow to 1/32 s per question at question 82 (6s limit). Good luck.''')
- input('''When you're ready to continue, press the Enter key while not holding the Shift key.
- The test will continue on the word "continue" 3 seconds after.
- > ''')
- time.sleep(1)
- print('On your marks,')
- time.sleep(1)
- print('get set,')
- time.sleep(1)
- print('continue.')
- x = generateNumber()
- y = generateNumber()
- ans = x + y
- start = time.time()
- limit = timeFromQuestion(question)
- totallimits += limit
- user = input(f'{limit}s: {x} + {y} = ')[:64]
- correct = False
- try:
- user = float(user)
- correct = user == ans
- except:
- pass
- timetaken = time.time() - start
- totaltimea += timetaken
- print(f'''{'{:.3f}'.format(timetaken)}s; {'{:.3f}'.format(limit - timetaken)}s left''')
- timedout = timetaken > limit
- if correct:
- correctcount += 1
- totaltimec += timetaken
- else:
- lives -= 1
- print(f'Not correct ({ans}).')
- if timedout:
- print('Ran out of time.')
- if correct:
- lives -= 1
- timedoutcount += 1
- if timedout or not correct:
- print(f"{lives} {'life' if lives == 1 else 'lives'} left.")
- fails.append({
- 'n': question,
- 'incorrect': not correct,
- 'question': [x, y, ans, user],
- 'timedout': timedout,
- 'timetaken': timetaken,
- 'limit': limit
- })
- question += 1
- input(f"""The test has ended.
- === RESULTS (using {startlives} lives) ===
- Version: {version}
- Questions reached: {question} (q{question-1})
- (press enter without shift to continue)""")
- print(f"""Questions correct: {correctcount}
- Questions incorrect: {question - correctcount}
- Accuracy: {'{:.3f}'.format(correctcount / question * 100)}%""")
- if correctcount:
- print(f"Average time taken (correct): {'{:.3f}'.format(totaltimec / correctcount)}s")
- print(f"Average time taken: {'{:.3f}'.format(totaltimea / question)}s")
- print(f"Total time taken: {'{:.3f}'.format(totaltimea)}s")
- print("== Fail reasons ==")
- for i in range(len(fails)):
- fail = fails[i]
- print(f'Fail #{i+1} @ q{fail["n"]}: {resultsFailDisplay(fail)}')
- input('\nPress Enter without Shift to exit > ')
Advertisement
Add Comment
Please, Sign In to add comment