<commit_before>/*
Write a program that reads a message, then checks whether it’s a palindrome (the letters in the message are the same from left to right as from right to left). Ignore all characters that are not letters only relevant are letter A-Z,a-z. A single character is a palindrome, and the empty message is considered a palindrome as well (this includes a message that consists of only non-letter characters).
% palindrome
Enter a message: He lived as a devil, eh?
Palindrome
% palindrome
Enter a message: Anne, I stay a day at Sienna.
Palindrome
% palindrome
Enter a message: Madam, I am Adam.
Not a palindrome
%
The maximum length of the message is 40 characters. Reading of the message should stop when more than 40 characters are read, or when the character ’\n’ is read (additional characters are ignored). The two possible messages printed by the program are “Palindrome” and “Not a palindrome”.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// defines allowed length of message
#define maxchars 41

int main() {

    char message[maxchars] = {'\0'};
    int countmsg = 0;
    int bla[] = {1,2,3};
    int (*b)[];
    b = &bla;
    char (*p)[maxchars];
    p = &message;
    int i = 0;


    printf("palindrome\n");
    printf("Enter a message: ");
    fgets(message, maxchars, stdin);

    /*  As newline characters are also counted with strlen(), a potential '\n' character needs to be replaced with the null terminator.  */
    for (i=0;i<maxchars;i++) {
        if(message[i] == '\n') {
            message[i] = '\0';
            break;
        }
    }
    countmsg = strlen(message);

    // p = &message;

    printf("message length: %d\n", countmsg);
    printf("message: %s\n", message);
    printf("first letter: %d\n", (*b)[0]);
    printf("first letter: %c\n", (*p)[0]);

    printf("last letter: %c\n", (*p)[countmsg-1]);
    printf("prev to last letter: %c\n", (*p)[countmsg-2]);


    // printf("last letter: %s\n", (*p)[countmsg-1]);


    // if () {

    // }

    return 0;
}
<commit_msg>added steps to take to create the program, removed unneeded test code<commit_after>/*
Write a program that reads a message, then checks whether it’s a palindrome (the letters in the message are the same from left to right as from right to left). Ignore all characters that are not letters only relevant are letter A-Z,a-z. A single character is a palindrome, and the empty message is considered a palindrome as well (this includes a message that consists of only non-letter characters).
% palindrome
Enter a message: He lived as a devil, eh?
Palindrome
% palindrome
Enter a message: Anne, I stay a day at Sienna.
Palindrome
% palindrome
Enter a message: Madam, I am Adam.
Not a palindrome
%
The maximum length of the message is 40 characters. Reading of the message should stop when more than 40 characters are read, or when the character ’\n’ is read (additional characters are ignored). The two possible messages printed by the program are “Palindrome” and “Not a palindrome”.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// defines allowed length of message -> allowed chars + 1x newline
#define maxchars 41

int main() {

    char message[maxchars] = {'\0'};
    int countmsg = 0;
    // int bla[] = {1,2,3};
    // int (*b)[] = &bla;
    char (*p)[maxchars] = &message;
    int i = 0;

    printf("palindrome\n");
    printf("Enter a message: ");
    fgets(message, maxchars, stdin);

    /*  As newline characters are also counted with strlen(), a potential '\n' character needs to be replaced with the null terminator.  */
    for (i=0;i<maxchars;i++) {
        if(message[i] == '\n') {
            message[i] = '\0';
            break;
        }
    }
    countmsg = strlen(message);

    /*  STEPS
        separate the input into alphabetical and non-alphabetical characters, put them into two separate arrays (use ASCII instead of checking against all letters!*)

        if both arrays are empty -> palindrome
        if the array with alphabetic chars is empty -> palindrome

        if the array with alphabetic chars is not empty:
        adjust countmsg (count length of array)

        if there's only one letter -> palindrome

        if there's more than one letter:
        - divide countmsg by two, save result in variable looptimes
        - check the first letter against last, 2nd against one but last etc., so (*p)[0] vs. (*p)[countmsg-1], (*p)[1] vs. (*p)[countmsg-2] => (*p)[i] vs. (*p)[countmsg-i-1] looptimes times

        *ASCII table
        A-Z ... 65-90
        a-z ... 97-122
    */

    printf("message length: %d\n", countmsg);
    printf("message: %s\n", message);
    printf("first letter: %c\n", (*p)[0]);
    printf("last letter: %c\n", (*p)[countmsg-1]);

    return 0;
}

{'fraction_non_alphanumeric': 0.119916142557652, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 3.0227655986509276, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '1304342', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1425, 'n_words': 612}