Created
March 24, 2024 11:23
-
-
Save robert-saramet/365fce56553135182028d3a6c14501c5 to your computer and use it in GitHub Desktop.
My solution to exercism.org/tracks/c/exercises/isogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string.h> | |
| #include <ctype.h> | |
| bool is_isogram(const char word[]) { | |
| if(word == NULL) | |
| return false; | |
| int count['z' - 'a' + 1] = {0}; | |
| for(size_t i = 0; i < strlen(word); i++) { | |
| char c = tolower(word[i]); | |
| if(c >= 'a' && c <= 'z') | |
| if(++count[c - 'a'] > 1) | |
| return false; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment