diff options
author | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
commit | 321825828ac918bad28d0597a8616c6dc9802c3c (patch) | |
tree | 0b8e9cb1012197750eb58e972736319b2a6abac2 /c/pangram/src | |
parent | 2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff) | |
download | exercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz |
Add solved exercises
Diffstat (limited to 'c/pangram/src')
-rw-r--r-- | c/pangram/src/pangram.c | 17 | ||||
-rw-r--r-- | c/pangram/src/pangram.h | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/c/pangram/src/pangram.c b/c/pangram/src/pangram.c new file mode 100644 index 0000000..d23ed9d --- /dev/null +++ b/c/pangram/src/pangram.c @@ -0,0 +1,17 @@ +#include "pangram.h" +#include <ctype.h> +#include <string.h> + +bool is_pangram(const char *sentence) { + if (sentence == NULL) return false; + + bool seen[26] = {0}; + for (size_t idx = 0; sentence[idx] != '\0'; idx++) { + unsigned char cur = tolower((unsigned char) sentence[idx]); + if ('a' <= cur & cur <= 'z') seen[cur - 'a'] = true; + } + + for (short idx = 0; idx < 26; idx++) + if (!seen[idx]) return false; + return true; +} diff --git a/c/pangram/src/pangram.h b/c/pangram/src/pangram.h new file mode 100644 index 0000000..e95d685 --- /dev/null +++ b/c/pangram/src/pangram.h @@ -0,0 +1,8 @@ +#ifndef PANGRAM_H +#define PANGRAM_H + +#include <stdbool.h> + +bool is_pangram(const char *sentence); + +#endif |