diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-29 02:13:57 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-29 02:13:57 +0000 |
commit | a664bf7383b41c5f266485454154b516e4d1e164 (patch) | |
tree | 36be20478e7b311669d6bc39f39ac219ff382b29 /wk5/pset/speller/test.c | |
parent | b236b6800f7d04e307ff8d1b3eb19dbe357e63b6 (diff) |
Sun, Apr 28, 2024, 7:13 PM -07:00
Diffstat (limited to 'wk5/pset/speller/test.c')
-rw-r--r-- | wk5/pset/speller/test.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/wk5/pset/speller/test.c b/wk5/pset/speller/test.c new file mode 100644 index 0000000..1b03355 --- /dev/null +++ b/wk5/pset/speller/test.c @@ -0,0 +1,20 @@ +#include <cs50.h> +#include <ctype.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +// Hashes word to a number +int main(void) +{ + char *word = "cat"; + // (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 += toupper(word[i]) - 'A'; + } + return val %= 26; +} |