Skip to content

Instantly share code, notes, and snippets.

@robert-saramet
Created March 24, 2024 11:23
Show Gist options
  • Select an option

  • Save robert-saramet/365fce56553135182028d3a6c14501c5 to your computer and use it in GitHub Desktop.

Select an option

Save robert-saramet/365fce56553135182028d3a6c14501c5 to your computer and use it in GitHub Desktop.
My solution to exercism.org/tracks/c/exercises/isogram
#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