Samyak2 / toipe

yet another typing test, but crab flavoured
MIT License
596 stars 31 forks source link

Fix WPM score #21

Closed Samyak2 closed 2 years ago

Samyak2 commented 2 years ago

What and why?

Currently, the WPM (words per minute) score is calculated as such:

wpm = (correctly typed characters / minutes) / (number of words / number of chars)

The (number of words / number of chars) is an estimate of the average number of chars in a word.

This has a few issues:

A big thank you to Darrien Glasser (author of terminal-typeracer) for explaining the issue thoroughly and providing the solution: https://www.reddit.com/r/rust/comments/tvamfz/comment/i3ewppb/

How?

A good way to calculate the WPM can be found here. To summarize, the final WPM will be:

wpm = ((correctly typed characters) / 5 - (uncorrected errors)) / minutes

A change will have to be made in correctly typed characters since currently the counter will keep increasing if the same char is backspaced and typed repeatedly.