by isogram i mean a unique occurencce of a character, to not be repeated twice either upper or lowercased
#include <stdio.h>
#include <stdbool.h>
int main(){
int j=0;
unsigned short alphabet_poz[52][2];
char phrase[]="hey there";
unsigned short phrase_len,alphabet_poz_len;
// here at first i thought that the uniqueness also concerns the UpperCase & LowerCase but it's not
// meaning that A==a
for (char alpha='A'; alpha<='Z'; alpha++) {
alphabet_poz[j][0]=alpha;
alphabet_poz[j][1]=0;
j++;
}
for (char alpha='a'; alpha<='z'; alpha++) {
alphabet_poz[j][0]=alpha;
alphabet_poz[j][1]=0;
j++;
}
phrase_len=sizeof(phrase);
alphabet_poz_len=sizeof(alphabet_poz)/sizeof(alphabet_poz[0]);
// here it gets quiet messy so bare with me
for (int index=0; index<phrase_len; index=index+1) {
// iterating over each character in the phrase
for (int iterv0=0; iterv0<=alphabet_poz_len/2; iterv0++) {
// here i divided by 2 the alpha_poz len cause it's 52 i only wanted the first 26, and i'm adding 26 later on to find it's lowercase alt
int iterv1=iterv0+26; // here
// i'm iterating over the alphabets to check whether the char is matching or not
if ((alphabet_poz[iterv0][1]==1 && phrase[index]==alphabet_poz[iterv0][0]) || (alphabet_poz[iterv1][1]==1 && phrase[index]==alphabet_poz[iterv1][0])) {
// iterv0 will go the range of Upper while iterv1 will go in the range of lower
return printf("it's not an isogram");
}
if ((phrase[index]==alphabet_poz[iterv0][0])||(phrase[index]==alphabet_poz[iterv1][0])) {
alphabet_poz[iterv1][1]++; // adding to occurence of both upper and lower
alphabet_poz[iterv1][0]++;
}
}
}
return printf("it's an isogram");
}