From 9092433cd215d514110e9c48370638da07decc81 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 29 Apr 2024 05:15:47 +0000 Subject: Sun, Apr 28, 2024, 10:15 PM -07:00 --- wk5/pset/speller/dictionary.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'wk5') diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c index 51ab6d7..cd10c35 100644 --- a/wk5/pset/speller/dictionary.c +++ b/wk5/pset/speller/dictionary.c @@ -30,6 +30,14 @@ bool check(const char *word) int val = hash(word); node *current = table[val]; + // buffer string becasue word is const + char *buff + // make word lowercase + for (int i = 0; word[i] != '\0'; i++) + { + word[i] = tolower(word[i]); + } + // check all nodes in the bucket while (current != NULL) { @@ -47,12 +55,6 @@ bool check(const char *word) // Hashes word to a number unsigned int hash(const char *word) { - // (sum of (letter - 'A') % 26) of a word to get a value of where to store it in the hash table - // int val = 0; - // for (int i = 0; word[i] != '\0'; i++) - // { - // val += (word[i] % 26); - // } return (tolower(word[0]) % 26); } -- cgit v1.2.3