From 8d5614a23aafce7e16b10efa6b4b653b43d25d92 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 14 Sep 2017 21:13:09 -0400 Subject: Count 5 letters as a word --- bin/typo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/typo.c b/bin/typo.c index e08cb723..468fcbe5 100644 --- a/bin/typo.c +++ b/bin/typo.c @@ -56,12 +56,12 @@ int main() { time_t start = time(NULL); if (start < 0) err(EX_OSERR, "time"); - int wordCount = 0; + int letterCount = 0; for (;;) { time_t now = time(NULL); if (now < 0) err(EX_OSERR, "time"); - double wpm = (double)wordCount / difftime(now, start) * 60; + double wpm = (double)letterCount / 5.0 / difftime(now, start) * 60.0; char *wpmDisplay; int len = asprintf(&wpmDisplay, "%.2f WPM ", wpm); @@ -79,7 +79,7 @@ int main() { for (size_t i = 0; i < targetsLen; ++i) { if (strcmp(word, targets[i])) continue; setTarget(i); - wordCount++; + letterCount += strlen(word); break; } } -- cgit 1.4.1