Skip to content

Commit 3caa124

Browse files
Merge pull request steam-bell-92#1078 from nyxsky404/fix/typing-speed-wpm-calculation
fix: calculate WPM based on correctly typed words in Typing Speed Tester
2 parents 7da7c8c + 620e17c commit 3caa124

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

utilities/Typing-Speed-Tester/Typing-Speed-Tester.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@
7070
# Calculate time
7171
time_taken = end_time - start_time
7272

73-
# Calculate words per minute
74-
words = len(sentence.split())
75-
wpm = (words / time_taken) * 60 if time_taken > 0 else 0
73+
# Calculate words per minute based on typed text
74+
sentence_words = sentence.split()
75+
typed_words = typed_text.split()
76+
correct_words = sum(
77+
1 for i, word in enumerate(typed_words)
78+
if i < len(sentence_words) and word == sentence_words[i]
79+
)
80+
wpm = (correct_words / time_taken) * 60 if time_taken > 0 else 0
7681

7782
# Calculate accuracy
7883
correct_chars = 0
@@ -85,7 +90,7 @@
8590
# Results
8691
print("\n🎉 ===== TEST COMPLETED ===== 🎉")
8792
print(f"⏱️ Time Taken : {time_taken:.2f} seconds")
88-
print(f"🚀 Typing Speed : {wpm:.2f} WPM")
93+
print(f"🚀 Net WPM : {wpm:.2f} WPM")
8994
print(f"🎯 Accuracy : {accuracy:.2f}%")
9095

9196
# Performance feedback

0 commit comments

Comments
 (0)