<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM 26

int create_letter_distribution_program( );
int count_letters(char);
int counter[ NUM ];
char lTTe[ NUM ];

int main () {

FILE *fp;
char ch;
int i;
for( i = 0 ; i < NUM ; i++ ) {
counter[ i ]=0;
lTTe [ i ] = 'a' + i;
}
fp = fopen("file.txt", "w");
while( ch != '\n'  )
{
ch = getchar();
if( (ch>='a' && ch <= 'z') || (ch>='A' && ch<='Z') || ch==' ')
fputc(ch, fp);
}
fclose(fp); 
create_letter_distribution_program();
    return 0;
}

int count_letters( char letter ) {
    int num_letter;
    if ( letter >= 'a' && letter <= 'z' ) {
        letter = letter - 'a';
        for ( num_letter = 0 ; letter > 0 ; letter-- ) num_letter++;
        counter[ num_letter ]++;
    } else if ( letter >= 'A' && letter <= 'Z' ){
        letter = letter - 'A';
        for ( num_letter = 0 ; letter > 0 ; letter-- ) num_letter++;
        counter[ num_letter ]++;
    }
    return 0;
}

int create_letter_distribution_program( ) {
 int i, swap, m, k;
  char c,swap_c;
   FILE *fp;
   fp = fopen( "file.txt" , "r");
   if(!fp) return -1;
  else {
   while(!feof(fp)){
   c = fgetc(fp);  
 count_letters(c);
    }
     fclose(fp);
        for( k = 0 ; k < NUM ; k++ ) {
            m=k;
            for ( i = k+1; i < NUM; i++ ) {
                if( counter [ m ] < counter [ i ] ) {
                    m = i;
                }
            }
            swap = counter [ m ];
            counter [ m ] = counter [ k ];
            counter [ k ] = swap;
            swap_c = lTTe [ m ];
            lTTe [ m ] = lTTe [ k ];
            lTTe [ k ] = swap_c;
        }
        for(i=0; i<NUM; i++) {
        for( k = 0 ; k < NUM ; k++ ) {
        if( counter[k] == counter[k+1] && k < NUM-1 ) {
         if( lTTe[ k ] > lTTe[ k + 1 ] ) {
                  swap = counter [ k+1 ];
                  counter [ k+1 ] = counter [ k ];
                  counter [ k ] = swap;
                  swap_c = lTTe [ k+1 ];
                  lTTe [ k+1 ] = lTTe [ k ];
                  lTTe [ k ] = swap_c;
                    }
                }
            }
        }
        for ( i = 0; i < NUM ; i++ ) {
            printf("%c : %d \n", lTTe[i], counter[i]);
        }
        return 0;
    }
}
<commit_msg>task3.c<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int create_letter_distribution_diagram( );
int count_letters(char);
int counter[26];
char lTTe[26];

int main () {

FILE *fp;
char ch;
int i;
for( i = 0 ; i <26; i++ ) {
counter[ i ]=0;
lTTe [ i ] = 'a' + i;
}
fp = fopen("file.txt", "w");
while( ch != '\n'  )
{
ch = getchar();
if( (ch>='a' && ch <= 'z') || (ch>='A' && ch<='Z') || ch==' ')
fputc(ch, fp);
}
fclose(fp); 
create_letter_distribution_diagram();
    return 0;
}

int count_letters( char letter ) {
    int num_letter;
    if ( letter >= 'a' && letter <= 'z' ) {
        letter = letter - 'a';
        for ( num_letter = 0 ; letter > 0 ; letter-- ) num_letter++;
        counter[ num_letter ]++;
    } else if ( letter >= 'A' && letter <= 'Z' ){
        letter = letter - 'A';
        for ( num_letter = 0 ; letter > 0 ; letter-- ) num_letter++;
        counter[ num_letter ]++;
    }
    return 0;
}

int create_letter_distribution_diagram( ) {
 int i, swap, m, k;
  char c,swap_c;
   FILE *fp;
   fp = fopen( "file.txt" , "r");
   if(!fp) return -1;
  else {
   while(!feof(fp)){
   c = fgetc(fp);  
 count_letters(c);
    }
     fclose(fp);
        for( k = 0 ; k < 26 ; k++ ) {
            m=k;
            for ( i = k+1; i < 26; i++ ) {
                if( counter [ m ] < counter [ i ] ) {
                    m = i;
                }
            }
            swap = counter [ m ];
            counter [ m ] = counter [ k ];
            counter [ k ] = swap;
            swap_c = lTTe [ m ];
            lTTe [ m ] = lTTe [ k ];
            lTTe [ k ] = swap_c;
        }
        for(i=0; i<26; i++) {
        for( k = 0 ; k < 26; k++ ) {
        if( counter[k] == counter[k+1] && k < 26-1 ) {
         if( lTTe[ k ] > lTTe[ k + 1 ] ) {
                  swap = counter [ k+1 ];
                  counter [ k+1 ] = counter [ k ];
                  counter [ k ] = swap;
                  swap_c = lTTe [ k+1 ];
                  lTTe [ k+1 ] = lTTe [ k ];
                  lTTe [ k ] = swap_c;
                    }
                }
            }
        }
        for ( i = 0; i < 26 ; i++ ) {
            printf("%c : %d \n", lTTe[i], counter[i]);
        }
        return 0;
    }
}

{'fraction_non_alphanumeric': 0.18254319893664156, 'fraction_numerical': 0.014399645547186531, 'mean_word_length': 1.441860465116279, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1747459', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1649, 'n_words': 437}