diff options
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 |