Skip to content

Conversation

@HotWheelzCodez
Copy link

@HotWheelzCodez HotWheelzCodez commented Mar 23, 2025

I created a simple python script to type out a challenge for me and realized that I was able to type over 1000 words per minute with, I add a quick "half assed" fix for it. In the getCPM method in ResultCalulationService I made it so it just returns 0 if the words per minute is greater than 300, there may be a better implementation for this due to the fact I am still learning the codebase.

… minute is above a certain threshold, aka if the user is using a program to type for them
Copy link

@MickaelRiego MickaelRiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably set the WPM limit to the world record, which I believe I saw was 216 WPM. Also, we need something better than just "0." Maybe we could add a message asking them to type manually?

But good idea !

Comment on lines 24 to 29
const totalWordLength = words.reduce((sum, word) => sum + word.length, 0);
const avgWordLength = totalWordLength / words.length;
const wpm = cpm / avgWordLength;
if (wpm > 300) { // Abitrary value, change as needed, if cpm is greater they are most likely using an automation program
return 0; // Simply give them no score
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, but I'm happy to move forward with this, but could you just change the calculation to wpm=cpm/5 instead as this is the commonly used wpm/cpm conversion

@HotWheelzCodez
Copy link
Author

Just went ahead and update that, also refactored the function slightly with a little bit better error handling. Let me know though if you want me to roll it back and just souly update the calculation to be 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants