%{
#include <stdio.h>
#include <ctype.h>
#include <string.h>
%}

%%

/* Objective 1: Extract numbers */
[0-9]+      { printf("%s\n", yytext); }

/* Objective 2: Replace 'charusat' with 'university' */
[Cc]harusat  { printf("university"); }

/* Objective 3: Count characters, words, and lines */
.            { char_count++; }
\n           { line_count++; word_count++; }
[ \t]+       { word_count++; }

/* Objective 4: Password validation */
^[a-zA-Z0-9*;#$@]{9,15}$ {
    int has_upper = 0, has_lower = 0, has_digit = 0, has_symbol = 0;
    for (int i = 0; i < yyleng; i++) {
        if (isupper(yytext[i])) has_upper = 1;
        if (islower(yytext[i])) has_lower = 1;
        if (isdigit(yytext[i])) has_digit = 1;
        if (strchr("*;#$@", yytext[i])) has_symbol = 1;
    }
    if (has_upper && has_lower && has_digit && has_symbol) {
        printf("Valid password\n");
    } else {
        printf("Invalid password\n");
    }
}

%%

int char_count = 0, word_count = 1, line_count = 0;

int main() {
    yylex();
    printf("Characters: %d\n", char_count);
    printf("Words: %d\n", word_count);
    printf("Lines: %d\n", line_count);
    return 0;
}

int yywrap() {
    return 1;
}