diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8fc1b9c..eec1e44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ # ============================================================================== -# Pre-commit Configuration - AGGRESSIVE Python Linting & Formatting +# Pre-commit Configuration - Multi-language Linting & Formatting # ============================================================================== # Install: pre-commit install # Run all: pre-commit run --all-files @@ -262,6 +262,62 @@ repos: - id: shellcheck args: [--severity=warning] + # =========================================================================== + # CLANG-FORMAT - C/C++ code formatting + # =========================================================================== + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.6 + hooks: + - id: clang-format + types_or: [c, c++] + + # =========================================================================== + # CPPCHECK - C/C++ static analysis + # =========================================================================== + - repo: local + hooks: + - id: cppcheck + name: cppcheck + entry: cppcheck + language: system + types_or: [c, c++] + args: + - --enable=warning,style,performance,portability + - --inconclusive + - --force + - --quiet + - --error-exitcode=1 + - --inline-suppr + - --suppress=missingIncludeSystem + - --std=c11 + + # =========================================================================== + # FLAWFINDER - C/C++ security scanner + # =========================================================================== + - repo: local + hooks: + - id: flawfinder + name: flawfinder + entry: flawfinder + language: system + types_or: [c, c++] + args: + - --error-level=4 + - --quiet + - --columns + + # =========================================================================== + # ESLINT - TypeScript/JavaScript linting + # =========================================================================== + - repo: local + hooks: + - id: eslint + name: eslint + entry: npx eslint --no-warn-ignored + language: system + types_or: [ts, tsx] + files: ^TS/ + # =========================================================================== # REMOVE EMPTY DIRECTORIES - Clean up empty folders in the repo # =========================================================================== diff --git a/C/vocabulary_curve/main.c b/C/vocabulary_curve/main.c index 6ababe4..985d978 100644 --- a/C/vocabulary_curve/main.c +++ b/C/vocabulary_curve/main.c @@ -9,81 +9,90 @@ * ./vocabulary_curve test.txt 50 */ +#include +#include #include #include #include -#include -#include #define MAX_WORD_LEN 64 #define MAX_WORDS 500000 #define MAX_UNIQUE_WORDS 100000 -#define HASH_SIZE 200003 /* Prime number for better distribution */ +#define HASH_SIZE 200003 /* Prime number for better distribution */ /* Word entry for hash table */ -typedef struct WordEntry { - char word[MAX_WORD_LEN]; - int count; - int rank; /* 1-indexed rank by frequency (1 = most common) */ +typedef struct WordEntry +{ + char word[MAX_WORD_LEN]; + int count; + int rank; /* 1-indexed rank by frequency (1 = most common) */ struct WordEntry *next; } WordEntry; /* Hash table for word lookup */ static WordEntry *hash_table[HASH_SIZE]; static WordEntry *all_entries[MAX_UNIQUE_WORDS]; -static int num_unique_words = 0; +static int num_unique_words = 0; /* All words in order of appearance - store POINTERS not indices */ static WordEntry *word_sequence[MAX_WORDS]; -static int num_words = 0; +static int num_words = 0; /* Result for each excerpt length */ -typedef struct { +typedef struct +{ int excerpt_length; int min_vocab_needed; - int start_pos; /* Start position in word_sequence */ + int start_pos; /* Start position in word_sequence */ } ExcerptResult; /* Simple hash function */ -static unsigned int hash_word(const char *word) { +static unsigned int hash_word(const char *word) +{ unsigned int hash = 5381; - int c; - while ((c = *word++)) { + int c; + while ((c = *word++)) + { hash = ((hash << 5) + hash) + c; } return hash % HASH_SIZE; } /* Find or create word entry */ -static WordEntry *get_or_create_word(const char *word) { - unsigned int h = hash_word(word); - WordEntry *entry = hash_table[h]; +static WordEntry *get_or_create_word(const char *word) +{ + unsigned int h = hash_word(word); + WordEntry *entry = hash_table[h]; - while (entry) { - if (strcmp(entry->word, word) == 0) { + while (entry) + { + if (strcmp(entry->word, word) == 0) + { return entry; } entry = entry->next; } /* Create new entry */ - if (num_unique_words >= MAX_UNIQUE_WORDS) { + if (num_unique_words >= MAX_UNIQUE_WORDS) + { fprintf(stderr, "Too many unique words\n"); exit(1); } entry = malloc(sizeof(WordEntry)); - if (!entry) { + if (!entry) + { fprintf(stderr, "Memory allocation failed\n"); exit(1); } strncpy(entry->word, word, MAX_WORD_LEN - 1); entry->word[MAX_WORD_LEN - 1] = '\0'; - entry->count = 0; - entry->rank = 0; - entry->next = hash_table[h]; - hash_table[h] = entry; + entry->count = 0; + entry->rank = 0; + entry->next = hash_table[h]; + hash_table[h] = entry; all_entries[num_unique_words++] = entry; @@ -91,41 +100,48 @@ static WordEntry *get_or_create_word(const char *word) { } /* Compare function for sorting by frequency (descending) */ -static int compare_by_count(const void *a, const void *b) { +static int compare_by_count(const void *a, const void *b) +{ const WordEntry *wa = *(const WordEntry **)a; const WordEntry *wb = *(const WordEntry **)b; - return wb->count - wa->count; /* Descending */ + return wb->count - wa->count; /* Descending */ } /* Check if character is part of a word */ -static bool is_word_char(int c) { - return isalnum(c) || c == '_' || (unsigned char)c >= 128; -} +static bool is_word_char(int c) { return isalnum(c) || c == '_' || (unsigned char)c >= 128; } /* Read and process file */ -static bool process_file(const char *filename) { +static bool process_file(const char *filename) +{ FILE *fp = fopen(filename, "r"); - if (!fp) { + if (!fp) + { fprintf(stderr, "Cannot open file: %s\n", filename); return false; } char word[MAX_WORD_LEN]; - int word_len = 0; - int c; + int word_len = 0; + int c; - while ((c = fgetc(fp)) != EOF) { - if (is_word_char(c)) { - if (word_len < MAX_WORD_LEN - 1) { + while ((c = fgetc(fp)) != EOF) + { + if (is_word_char(c)) + { + if (word_len < MAX_WORD_LEN - 1) + { word[word_len++] = tolower(c); } - } else if (word_len > 0) { + } + else if (word_len > 0) + { word[word_len] = '\0'; WordEntry *entry = get_or_create_word(word); entry->count++; - if (num_words >= MAX_WORDS) { + if (num_words >= MAX_WORDS) + { fprintf(stderr, "Too many words in file\n"); fclose(fp); return false; @@ -139,12 +155,14 @@ static bool process_file(const char *filename) { } /* Handle last word if file doesn't end with whitespace */ - if (word_len > 0) { - word[word_len] = '\0'; + if (word_len > 0) + { + word[word_len] = '\0'; WordEntry *entry = get_or_create_word(word); entry->count++; - if (num_words < MAX_WORDS) { + if (num_words < MAX_WORDS) + { word_sequence[num_words++] = entry; } } @@ -154,7 +172,8 @@ static bool process_file(const char *filename) { } /* Assign ranks based on frequency */ -static void assign_ranks(void) { +static void assign_ranks(void) +{ /* Sort all_entries by frequency (this doesn't affect word_sequence) */ qsort(all_entries, num_unique_words, sizeof(WordEntry *), compare_by_count); @@ -162,13 +181,19 @@ static void assign_ranks(void) { * Words with same frequency get same rank. * Next rank is current_position + 1 (skipping numbers). * Example: counts 5,3,3,2 -> ranks 1,2,2,4 (not 1,2,3,4) */ - for (int i = 0; i < num_unique_words; i++) { - if (i == 0) { + for (int i = 0; i < num_unique_words; i++) + { + if (i == 0) + { all_entries[i]->rank = 1; - } else if (all_entries[i]->count == all_entries[i-1]->count) { + } + else if (all_entries[i]->count == all_entries[i - 1]->count) + { /* Same frequency as previous word - same rank */ - all_entries[i]->rank = all_entries[i-1]->rank; - } else { + all_entries[i]->rank = all_entries[i - 1]->rank; + } + else + { /* Different frequency - rank is position + 1 */ all_entries[i]->rank = i + 1; } @@ -176,7 +201,8 @@ static void assign_ranks(void) { } /* Analyze excerpt and return max rank needed */ -static int analyze_excerpt(int start, int length) { +static int analyze_excerpt(int start, int length) +{ /* Track which entries we've seen using a simple visited array */ /* We use the rank field is already assigned, so we can check uniqueness */ static bool seen_rank[MAX_UNIQUE_WORDS + 1]; @@ -184,13 +210,16 @@ static int analyze_excerpt(int start, int length) { int max_rank = 0; - for (int i = start; i < start + length; i++) { + for (int i = start; i < start + length; i++) + { WordEntry *entry = word_sequence[i]; - int rank = entry->rank; + int rank = entry->rank; - if (!seen_rank[rank]) { + if (!seen_rank[rank]) + { seen_rank[rank] = true; - if (rank > max_rank) { + if (rank > max_rank) + { max_rank = rank; } } @@ -200,56 +229,69 @@ static int analyze_excerpt(int start, int length) { } /* Find optimal excerpts for each length */ -static void find_optimal_excerpts(int max_length, ExcerptResult *results) { - for (int length = 1; length <= max_length && length <= num_words; length++) { +static void find_optimal_excerpts(int max_length, ExcerptResult *results) +{ + for (int length = 1; length <= max_length && length <= num_words; length++) + { int best_vocab = num_unique_words + 1; int best_start = 0; /* Slide window through text */ - for (int start = 0; start <= num_words - length; start++) { + for (int start = 0; start <= num_words - length; start++) + { int vocab_needed = analyze_excerpt(start, length); - if (vocab_needed < best_vocab) { + if (vocab_needed < best_vocab) + { best_vocab = vocab_needed; best_start = start; } } - results[length - 1].excerpt_length = length; + results[length - 1].excerpt_length = length; results[length - 1].min_vocab_needed = best_vocab; - results[length - 1].start_pos = best_start; + results[length - 1].start_pos = best_start; } } /* Print excerpt words */ -static void print_excerpt(int start, int length) { - for (int i = start; i < start + length; i++) { - if (i > start) printf(" "); +static void print_excerpt(int start, int length) +{ + for (int i = start; i < start + length; i++) + { + if (i > start) + printf(" "); printf("%s", word_sequence[i]->word); } } /* Print words needed (sorted by rank) */ -static void print_words_needed(int start, int length) { +static void print_words_needed(int start, int length) +{ /* Collect unique entries */ static WordEntry *unique_entries[MAX_UNIQUE_WORDS]; - static bool seen_rank[MAX_UNIQUE_WORDS + 1]; + static bool seen_rank[MAX_UNIQUE_WORDS + 1]; memset(seen_rank, 0, (num_unique_words + 1) * sizeof(bool)); int count = 0; - for (int i = start; i < start + length; i++) { + for (int i = start; i < start + length; i++) + { WordEntry *entry = word_sequence[i]; - if (!seen_rank[entry->rank]) { - seen_rank[entry->rank] = true; + if (!seen_rank[entry->rank]) + { + seen_rank[entry->rank] = true; unique_entries[count++] = entry; } } /* Sort by rank (simple bubble sort - small arrays) */ - for (int i = 0; i < count - 1; i++) { - for (int j = i + 1; j < count; j++) { - if (unique_entries[i]->rank > unique_entries[j]->rank) { - WordEntry *tmp = unique_entries[i]; + for (int i = 0; i < count - 1; i++) + { + for (int j = i + 1; j < count; j++) + { + if (unique_entries[i]->rank > unique_entries[j]->rank) + { + WordEntry *tmp = unique_entries[i]; unique_entries[i] = unique_entries[j]; unique_entries[j] = tmp; } @@ -257,14 +299,17 @@ static void print_words_needed(int start, int length) { } /* Print */ - for (int i = 0; i < count; i++) { - if (i > 0) printf(", "); + for (int i = 0; i < count; i++) + { + if (i > 0) + printf(", "); printf("%s(#%d)", unique_entries[i]->word, unique_entries[i]->rank); } } /* Print results */ -static void print_results(ExcerptResult *results, int max_length) { +static void print_results(ExcerptResult *results, int max_length) +{ printf("======================================================================\n"); printf("VOCABULARY LEARNING CURVE\n"); printf("======================================================================\n"); @@ -279,13 +324,16 @@ static void print_results(ExcerptResult *results, int max_length) { int prev_vocab = 0; int actual_max = max_length; - if (actual_max > num_words) actual_max = num_words; + if (actual_max > num_words) + actual_max = num_words; - for (int i = 0; i < actual_max; i++) { + for (int i = 0; i < actual_max; i++) + { ExcerptResult *r = &results[i]; printf("\n[Length %d] Vocab needed: %d", r->excerpt_length, r->min_vocab_needed); - if (r->min_vocab_needed > prev_vocab) { + if (r->min_vocab_needed > prev_vocab) + { printf(" (+%d)", r->min_vocab_needed - prev_vocab); } printf("\n"); @@ -303,7 +351,8 @@ static void print_results(ExcerptResult *results, int max_length) { printf("\n----------------------------------------------------------------------\n"); - if (actual_max > 0) { + if (actual_max > 0) + { ExcerptResult *final = &results[actual_max - 1]; printf("\nTo understand a %d-word excerpt,\n", final->excerpt_length); printf("you need to learn at minimum %d top words.\n", final->min_vocab_needed); @@ -311,17 +360,22 @@ static void print_results(ExcerptResult *results, int max_length) { } /* Free memory */ -static void cleanup(void) { - for (int i = 0; i < num_unique_words; i++) { +static void cleanup(void) +{ + for (int i = 0; i < num_unique_words; i++) + { free(all_entries[i]); } } /* Dump all vocabulary with ranks (for Python integration) */ -static void dump_vocabulary(int max_rank) { +static void dump_vocabulary(int max_rank) +{ printf("VOCAB_DUMP_START\n"); - for (int i = 0; i < num_unique_words; i++) { - if (all_entries[i]->rank <= max_rank) { + for (int i = 0; i < num_unique_words; i++) + { + if (all_entries[i]->rank <= max_rank) + { printf("%s;%d\n", all_entries[i]->word, all_entries[i]->rank); } } @@ -329,22 +383,28 @@ static void dump_vocabulary(int max_rank) { } /* Find longest excerpt using only top N words (inverse mode) */ -static void find_longest_excerpt(int max_vocab) { +static void find_longest_excerpt(int max_vocab) +{ /* Sliding window: find longest contiguous sequence where all words have rank <= max_vocab */ - int best_start = 0; + int best_start = 0; int best_length = 0; int left = 0; - for (int right = 0; right < num_words; right++) { + for (int right = 0; right < num_words; right++) + { /* If current word is outside our vocabulary, move left past it */ - if (word_sequence[right]->rank > max_vocab) { + if (word_sequence[right]->rank > max_vocab) + { left = right + 1; - } else { + } + else + { /* Current window [left, right] is valid */ int length = right - left + 1; - if (length > best_length) { + if (length > best_length) + { best_length = length; - best_start = left; + best_start = left; } } } @@ -361,10 +421,13 @@ static void find_longest_excerpt(int max_vocab) { printf("----------------------------------------------------------------------\n"); printf("\n"); - if (best_length == 0) { + if (best_length == 0) + { printf("No valid excerpt found with top %d words.\n", max_vocab); printf("The text may require rarer words from the very beginning.\n"); - } else { + } + else + { printf("LONGEST EXCERPT: %d words\n", best_length); printf("Position: words %d to %d\n", best_start + 1, best_start + best_length); printf("\n"); @@ -374,12 +437,14 @@ static void find_longest_excerpt(int max_vocab) { printf("\n"); /* Find the rarest word in the excerpt */ - int max_rank_used = 0; - const char *rarest_word = NULL; - for (int i = best_start; i < best_start + best_length; i++) { - if (word_sequence[i]->rank > max_rank_used) { + int max_rank_used = 0; + const char *rarest_word = NULL; + for (int i = best_start; i < best_start + best_length; i++) + { + if (word_sequence[i]->rank > max_rank_used) + { max_rank_used = word_sequence[i]->rank; - rarest_word = word_sequence[i]->word; + rarest_word = word_sequence[i]->word; } } printf("Rarest word used: %s (#%d)\n", rarest_word, max_rank_used); @@ -388,8 +453,10 @@ static void find_longest_excerpt(int max_vocab) { static bool seen_rank[MAX_UNIQUE_WORDS + 1]; memset(seen_rank, 0, (num_unique_words + 1) * sizeof(bool)); int unique_count = 0; - for (int i = best_start; i < best_start + best_length; i++) { - if (!seen_rank[word_sequence[i]->rank]) { + for (int i = best_start; i < best_start + best_length; i++) + { + if (!seen_rank[word_sequence[i]->rank]) + { seen_rank[word_sequence[i]->rank] = true; unique_count++; } @@ -400,49 +467,67 @@ static void find_longest_excerpt(int max_vocab) { printf("\n----------------------------------------------------------------------\n"); } -int main(int argc, char *argv[]) { - if (argc < 2) { +int main(int argc, char *argv[]) +{ + if (argc < 2) + { fprintf(stderr, "Usage: %s [options]\n", argv[0]); fprintf(stderr, "\nModes:\n"); fprintf(stderr, " (default) Find minimum vocab needed for each excerpt length\n"); - fprintf(stderr, " --max-vocab N INVERSE: Find longest excerpt using only top N words\n"); + fprintf(stderr, + " --max-vocab N INVERSE: Find longest excerpt using only top N words\n"); fprintf(stderr, "\nOptions:\n"); fprintf(stderr, " max_length Maximum excerpt length to analyze (default: 30)\n"); fprintf(stderr, " --dump-vocab [N] Output all words with ranks up to N\n"); fprintf(stderr, "\nExamples:\n"); - fprintf(stderr, " %s book.txt 50 # Analyze excerpts up to 50 words\n", argv[0]); - fprintf(stderr, " %s book.txt --max-vocab 500 # Find longest excerpt with top 500 words\n", argv[0]); + fprintf(stderr, " %s book.txt 50 # Analyze excerpts up to 50 words\n", + argv[0]); + fprintf(stderr, " %s book.txt --max-vocab 500 # Find longest excerpt with top 500 words\n", + argv[0]); return 1; } - const char *filename = argv[1]; - int max_length = 30; - bool dump_vocab = false; - int dump_max_rank = 0; - int max_vocab_mode = 0; /* 0 = normal mode, >0 = inverse mode with this vocab limit */ + const char *filename = argv[1]; + int max_length = 30; + bool dump_vocab = false; + int dump_max_rank = 0; + int max_vocab_mode = 0; /* 0 = normal mode, >0 = inverse mode with this vocab limit */ /* Parse arguments */ - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i], "--dump-vocab") == 0) { + for (int i = 2; i < argc; i++) + { + if (strcmp(argv[i], "--dump-vocab") == 0) + { dump_vocab = true; - if (i + 1 < argc && argv[i + 1][0] != '-') { + if (i + 1 < argc && argv[i + 1][0] != '-') + { dump_max_rank = atoi(argv[++i]); } - } else if (strcmp(argv[i], "--max-vocab") == 0) { - if (i + 1 < argc) { + } + else if (strcmp(argv[i], "--max-vocab") == 0) + { + if (i + 1 < argc) + { max_vocab_mode = atoi(argv[++i]); - if (max_vocab_mode < 1) { + if (max_vocab_mode < 1) + { fprintf(stderr, "Error: --max-vocab requires a positive number\n"); return 1; } - } else { + } + else + { fprintf(stderr, "Error: --max-vocab requires a number\n"); return 1; } - } else if (argv[i][0] != '-') { + } + else if (argv[i][0] != '-') + { max_length = atoi(argv[i]); - if (max_length < 1) max_length = 1; - if (max_length > 1000) max_length = 1000; + if (max_length < 1) + max_length = 1; + if (max_length > 1000) + max_length = 1000; } } @@ -450,11 +535,13 @@ int main(int argc, char *argv[]) { memset(hash_table, 0, sizeof(hash_table)); /* Process file */ - if (!process_file(filename)) { + if (!process_file(filename)) + { return 1; } - if (num_words == 0) { + if (num_words == 0) + { fprintf(stderr, "No words found in file\n"); return 1; } @@ -463,12 +550,15 @@ int main(int argc, char *argv[]) { assign_ranks(); /* Inverse mode: find longest excerpt with limited vocabulary */ - if (max_vocab_mode > 0) { + if (max_vocab_mode > 0) + { find_longest_excerpt(max_vocab_mode); /* Dump vocabulary if requested */ - if (dump_vocab) { - if (dump_max_rank == 0) dump_max_rank = max_vocab_mode; + if (dump_vocab) + { + if (dump_max_rank == 0) + dump_max_rank = max_vocab_mode; dump_vocabulary(dump_max_rank); } @@ -478,7 +568,8 @@ int main(int argc, char *argv[]) { /* Normal mode: find optimal excerpts */ ExcerptResult *results = malloc(max_length * sizeof(ExcerptResult)); - if (!results) { + if (!results) + { fprintf(stderr, "Memory allocation failed\n"); cleanup(); return 1; @@ -490,12 +581,15 @@ int main(int argc, char *argv[]) { print_results(results, max_length); /* Dump vocabulary if requested */ - if (dump_vocab) { + if (dump_vocab) + { /* If no max_rank specified, use the max from the excerpt */ - if (dump_max_rank == 0 && max_length > 0) { + if (dump_max_rank == 0 && max_length > 0) + { dump_max_rank = results[max_length - 1].min_vocab_needed; } - if (dump_max_rank > 0) { + if (dump_max_rank > 0) + { dump_vocabulary(dump_max_rank); } } diff --git a/CPP/miscelanious/Pi/main.cpp b/CPP/miscelanious/Pi/main.cpp index 9c91a24..271c4bd 100644 --- a/CPP/miscelanious/Pi/main.cpp +++ b/CPP/miscelanious/Pi/main.cpp @@ -1,25 +1,24 @@ -#include -#include #include +#include +#include const unsigned long long int ITERATIONS = 10000; -long double getPi() -{ - long double pi = 4; - bool negative = 1; - for(unsigned int i = 3; i < ITERATIONS; i += 2) - { - if(negative) pi -= 4.0 / i; - else pi += 4.0 / i; - negative = !negative; - } - std::cout << std::setprecision(2000) << pi << std::endl; - return pi; +long double getPi() { + long double pi = 4; + bool negative = 1; + for (unsigned int i = 3; i < ITERATIONS; i += 2) { + if (negative) + pi -= 4.0 / i; + else + pi += 4.0 / i; + negative = !negative; + } + std::cout << std::setprecision(2000) << pi << std::endl; + return pi; } -int main() -{ - getPi(); - return 0; +int main() { + getPi(); + return 0; } diff --git a/CPP/miscelanious/brydz/brydz.cpp b/CPP/miscelanious/brydz/brydz.cpp index b58b483..36d9297 100644 --- a/CPP/miscelanious/brydz/brydz.cpp +++ b/CPP/miscelanious/brydz/brydz.cpp @@ -1,11 +1,12 @@ #include #include -const std::vector ATUTY = {"BA", "Trefl", "Karo", "Kier", "Pik"}; +const std::vector ATUTY = {"BA", "Trefl", "Karo", "Kier", "Pik"}; const bool A_ID = 0; const bool B_ID = 1; -const std::vector GRACZE = {}; -const std::vector PO_PARTII {"Nikt", GRACZE[A_ID], GRACZE[B_ID], "Obaj Gracze"}; +const std::vector GRACZE = {}; +const std::vector PO_PARTII{"Nikt", GRACZE[A_ID], GRACZE[B_ID], + "Obaj Gracze"}; const int DOMYSLNE_LEWY = 6; const int BEZ_ATUTU_ID = 1; const int TREFL_ID = 2; @@ -19,392 +20,372 @@ const int MAKSYMALNY_LEW = 7; const int MINIMALNY_LEW = 1; const int ILOSC_LEW = 13; -void print(const std::string s) -{ - std::cout << s << std::endl; +void print(const std::string s) { std::cout << s << std::endl; } + +void tabela(std::vector punktyA, std::vector punktyB) { + + std::cout << "Numer Gry" << " Po Partii" << " " << GRACZE[A_ID] + << " " << GRACZE[B_ID] << std::endl; + for (int i = 0; i < punktyA.size(); i++) { + + std::cout << i + 1 << " " << PO_PARTII[i % CYKL_PO_PARTII] + << " " << punktyA[i] << " " + << punktyB[i] << std::endl; + } } -void tabela(std::vector punktyA, std::vector punktyB) -{ - - std::cout << "Numer Gry" << " Po Partii" << " " << GRACZE[A_ID] << " " << GRACZE[B_ID] << std::endl; - for(int i = 0; i < punktyA.size(); i++) - { - - std::cout << i + 1 << " " << PO_PARTII[i % CYKL_PO_PARTII] << " " << punktyA[i] << " " << punktyB[i] << std::endl; - } +void lwyAtut(int lwy, int atut) { + if (lwy == SZLEMIK) { + print("Wybrano szlemik!"); + return; + } + if (lwy == SZLEM) { + print("Wybrano szlema!"); + return; + } + std::cout << "Wybrano kontrakt: " << lwy << " " << ATUTY[atut - 1] + << std::endl; } -void lwyAtut(int lwy, int atut) -{ - if(lwy == SZLEMIK) - { - print("Wybrano szlemik!"); - return; - } - if(lwy == SZLEM) - { - print("Wybrano szlema!"); - return; - } - std::cout << "Wybrano kontrakt: " << lwy << " " << ATUTY[atut - 1] << std::endl; +int zagraneLwy() { + int lwy; + bool flagaLwy; + do { + flagaLwy = 0; + print("Ile lew?"); + char lwyC; + std::cin >> lwyC; + lwy = lwyC - '0'; + if (lwy < MINIMALNY_LEW) { + print("Podales za malo lew!"); + flagaLwy = 1; + } + + if (lwy > MAKSYMALNY_LEW) { + print("Podales za duzo lew!"); + flagaLwy = 1; + } + } while (flagaLwy); + return lwy; } -int zagraneLwy() -{ - int lwy; - bool flagaLwy; - do - { - flagaLwy = 0; - print("Ile lew?"); - char lwyC; - std::cin >> lwyC; - lwy = lwyC - '0'; - if(lwy < MINIMALNY_LEW) - { - print("Podales za malo lew!"); - flagaLwy = 1; - } - - if(lwy > MAKSYMALNY_LEW) - { - print("Podales za duzo lew!"); - flagaLwy = 1; - } - }while(flagaLwy); - return lwy; +int zagranyAtut(int lwy) { + int atut; + bool flagaAtut; + if (lwy > 6) + return 1; + do { + flagaAtut = 0; + print("Jaki atut?"); + print("1 - BA"); + print("2 - Trefl"); + print("3 - Karo"); + print("4 - Kier"); + print("5 - Pik"); + char atutC; + std::cin >> atutC; + atut = atutC - '0'; + if (atut < 1 || atut > 5) { + print("Wybrales zla liczbe!"); + flagaAtut = 1; + } + } while (flagaAtut); + return atut; } -int zagranyAtut(int lwy) -{ - int atut; - bool flagaAtut; - if(lwy > 6) return 1; - do - { - flagaAtut = 0; - print("Jaki atut?"); - print("1 - BA"); - print("2 - Trefl"); - print("3 - Karo"); - print("4 - Kier"); - print("5 - Pik"); - char atutC; - std::cin >> atutC; - atut = atutC - '0'; - if(atut < 1 || atut > 5) - { - print("Wybrales zla liczbe!"); - flagaAtut = 1; - } - }while(flagaAtut); - return atut; +bool zagranaKontra() { + char kontraC = '0'; + print("Czy zostala zagrana kontra?"); + print("1 - TAK"); + print("0 - NIE"); + std::cin >> kontraC; + bool kontraBool = kontraC - '0'; + return kontraBool; } -bool zagranaKontra() -{ - char kontraC = '0'; - print("Czy zostala zagrana kontra?"); - print("1 - TAK"); - print("0 - NIE"); - std::cin >> kontraC; - bool kontraBool = kontraC - '0'; - return kontraBool; +bool zagranaRekontra() { + char rekontraC = '0'; + print("Czy zostala zagrana rekontra?"); + print("1 - TAK"); + print("0 - NIE"); + std::cin >> rekontraC; + bool rekontraBool = rekontraC - '0'; + return rekontraBool; } -bool zagranaRekontra() -{ - char rekontraC = '0'; - print("Czy zostala zagrana rekontra?"); - print("1 - TAK"); - print("0 - NIE"); - std::cin >> rekontraC; - bool rekontraBool = rekontraC - '0'; - return rekontraBool; +void stanGry(int lwy, int atut, bool kontraBool, bool rekontraBool, + int ktoraGra, int ktoKontrakt) { + std::cout << "Kontrakt Wygrali: " << GRACZE[ktoKontrakt] << std::endl; + lwyAtut(lwy, atut); + if (kontraBool) { + if (rekontraBool) + print("Zostala zagrana REkontra!"); + else + print("Zostala zagrana Kontra!"); + } + std::cout << "Po partii sa: " << PO_PARTII[ktoraGra % 4] << std::endl; } -void stanGry(int lwy, int atut, bool kontraBool, bool rekontraBool, int ktoraGra, int ktoKontrakt) -{ - std::cout << "Kontrakt Wygrali: " << GRACZE[ktoKontrakt] << std::endl; - lwyAtut(lwy, atut); - if(kontraBool) - { - if(rekontraBool) print("Zostala zagrana REkontra!"); - else print("Zostala zagrana Kontra!"); - } - std::cout << "Po partii sa: " << PO_PARTII[ktoraGra % 4] << std::endl; +int ktoKontrakt() { + char ktoKontraktC; + print("Kto wygral Kontrakt?"); + std::cout << "1. " << GRACZE[A_ID] << std::endl; + std::cout << "2. " << GRACZE[B_ID] << std::endl; + std::cin >> ktoKontraktC; + int ktoKontraktI = ktoKontraktC - '1'; + std::cout << "ktoKontraktI " << ktoKontraktI; + return ktoKontraktI; } -int ktoKontrakt() -{ - char ktoKontraktC; - print("Kto wygral Kontrakt?"); - std::cout << "1. " << GRACZE[A_ID] << std::endl; - std::cout << "2. " << GRACZE[B_ID] << std::endl; - std::cin >> ktoKontraktC; - int ktoKontraktI = ktoKontraktC - '1'; - std::cout << "ktoKontraktI " << ktoKontraktI; - return ktoKontraktI; +int ileWpadek() { + std::string ileWpadekS; + print("ile lew wygrali obroncy?"); + std::cin >> ileWpadekS; + int ileWpadek = stoi(ileWpadekS); + return ileWpadek; } -int ileWpadek() -{ - std::string ileWpadekS; - print("ile lew wygrali obroncy?"); - std::cin >> ileWpadekS; - int ileWpadek = stoi(ileWpadekS); - return ileWpadek; +void punkty(std::vector &punktyA, std::vector &punktyB, int lwy, + int atut, bool kontraBool, bool rekontraBool, int ktoraGra, + int ktoKontraktI, bool rozgrywajacyWygral, int wpadki) { + int sumaPunktow = 0; + if (rozgrywajacyWygral) { + int zdobyteLewy = ILOSC_LEW - wpadki - DOMYSLNE_LEWY; + int nadrobki = zdobyteLewy - lwy; + int punktyZaLew; + std::cout << "wartosc kontraBool: " << kontraBool + << "; wartosc rekontraBool: " << rekontraBool << std::endl; + + // Lewy Deklarowane + if (atut == TREFL_ID || atut == KARO_ID) { + print("kontrakt TREFL lub KARO kazda karta kontraktowa za 20"); + punktyZaLew = 20; + if (kontraBool) { + print("kontra TREFL lub KARO, kazda karta kontraktowa za 40"); + punktyZaLew = 40; + } + if (rekontraBool) { + print("rekontra TREFL lub KARO, kazda karta kontraktowa za 80"); + punktyZaLew = 80; + } + + std::cout << "Ilosc lew w kontrakcie: " << lwy + << " do punktow dodaje sie " << lwy * punktyZaLew << std::endl; + sumaPunktow += (lwy * punktyZaLew); + } + + if (atut == KIER_ID || atut == PIK_ID) { + print("kontrakt KIER lub PIK, kazda kontraktowa 30"); + punktyZaLew = 30; + if (kontraBool) { + print("kontra KIER lub PIK, kazda kontraktowa za 60"); + punktyZaLew = 60; + } + if (rekontraBool) { + print("rekontra KIER lub PIK, kazda kontraktowa za 120"); + punktyZaLew = 120; + } + + std::cout << "Ilosc lew w kontrakcie: " << lwy + << " do punktow dodaje sie " << lwy * punktyZaLew << std::endl; + sumaPunktow += (lwy * punktyZaLew); + } + + if (atut == BEZ_ATUTU_ID) { + punktyZaLew = 30; + print("kontrakt BEZ_ATUTU, pierwsza lewa za 40, kazda nastepna za 30"); + sumaPunktow = 40; + if (kontraBool) { + print("kontrakt BEZ_ATUTU, pierwsza lewa za 80, kazda nastepna za 60"); + sumaPunktow = 80; + punktyZaLew = 60; + } + if (rekontraBool) { + print( + "kontrakt BEZ_ATUTU, pierwsza lewa za 160, kazda nastepna za 120"); + sumaPunktow = 160; + punktyZaLew = 120; + } + sumaPunktow += ((lwy - 1) * punktyZaLew); + } + + bool czyRozgrywajacyPoPartii = + (((ktoraGra % CYKL_PO_PARTII) - 1) == ktoKontraktI || + ktoraGra % CYKL_PO_PARTII == 3); + + if (lwy == SZLEMIK) { + if (czyRozgrywajacyPoPartii) + sumaPunktow += 750; + else + sumaPunktow += 500; + } + + if (lwy == SZLEM) { + if (czyRozgrywajacyPoPartii) + sumaPunktow += 1500; + else + sumaPunktow += 1000; + } + + bool dograna = (sumaPunktow >= 100); + if (dograna) { + if (czyRozgrywajacyPoPartii) + sumaPunktow += 500; + else + sumaPunktow += 300; + } else + sumaPunktow += 50; + + // Nadrobki + + if (!kontraBool && !rekontraBool) { + int punktyZaNadrobki = punktyZaLew; + sumaPunktow += nadrobki * punktyZaNadrobki; + } + if (kontraBool && !rekontraBool) { + int punktyZaNadrobki = 100; + if (czyRozgrywajacyPoPartii) + punktyZaNadrobki = 200; + sumaPunktow += nadrobki * punktyZaNadrobki; + } + + if (kontraBool && rekontraBool) { + + int punktyZaNadrobki = 200; + if (czyRozgrywajacyPoPartii) + punktyZaNadrobki = 400; + sumaPunktow += nadrobki * punktyZaNadrobki; + } + + if (kontraBool && !rekontraBool) + sumaPunktow += 50; + + if (kontraBool && rekontraBool) + sumaPunktow += 100; + std::cout << "Rozgrywajacy zdobyl: " << sumaPunktow << std::endl; + if (ktoKontraktI == A_ID) { + punktyA.push_back(sumaPunktow); + punktyB.push_back(0); + } else { + punktyB.push_back(sumaPunktow); + punktyA.push_back(0); + } + return; + } else { + int zebraneLewy = ILOSC_LEW - wpadki; + int lewyWpadkowe = (lwy + DOMYSLNE_LEWY) - zebraneLewy; + int sumaPunktow = 0; + bool broniacyPoPartii = + (((ktoraGra % CYKL_PO_PARTII) - 1) == !ktoKontraktI || + ktoraGra % CYKL_PO_PARTII == 3); + if (broniacyPoPartii) { + + if (!kontraBool && !rekontraBool) { + sumaPunktow = 100; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 100; + else + sumaPunktow += 0; + } + } + + if (kontraBool && !rekontraBool) { + sumaPunktow = 200; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 300; + else + sumaPunktow += 0; + } + } + + if (kontraBool && rekontraBool) { + sumaPunktow = 400; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 600; + else + sumaPunktow += 0; + } + } + } else { + if (!kontraBool && !rekontraBool) { + sumaPunktow = 50; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 50; + else + sumaPunktow += 0; + } + } + + if (kontraBool && !rekontraBool) { + sumaPunktow = 100; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 200; + else + sumaPunktow += 100; + } + } + + if (kontraBool && rekontraBool) { + sumaPunktow = 200; + for (int i = 1; i < lewyWpadkowe; i++) { + if (i < 4) + sumaPunktow += 400; + else + sumaPunktow += 200; + } + } + } + std::cout << "Broniacy zdobyli: " << sumaPunktow << std::endl; + if (ktoKontraktI == A_ID) { + punktyB.push_back(sumaPunktow); + punktyA.push_back(0); + } else { + punktyA.push_back(sumaPunktow); + punktyB.push_back(0); + } + return; + } } -void punkty(std::vector &punktyA, std::vector &punktyB, int lwy, int atut, bool kontraBool, bool rekontraBool, -int ktoraGra, int ktoKontraktI, bool rozgrywajacyWygral, int wpadki) -{ - int sumaPunktow = 0; - if(rozgrywajacyWygral) - { - int zdobyteLewy = ILOSC_LEW - wpadki - DOMYSLNE_LEWY; - int nadrobki = zdobyteLewy - lwy; - int punktyZaLew; - std::cout << "wartosc kontraBool: " << kontraBool << "; wartosc rekontraBool: " << rekontraBool << std::endl; +bool gra() { + bool koniecGry = 0; + std::vector punktyA; + std::vector punktyB; + do { + int ktoraGra = 0; + tabela(punktyA, punktyB); + int ktoKontraktI = ktoKontrakt(); + int lwy = zagraneLwy(); + int atut = zagranyAtut(lwy); + bool kontraBool = zagranaKontra(); + bool rekontraBool = 0; + if (kontraBool) + rekontraBool = zagranaRekontra(); + stanGry(lwy, atut, kontraBool, rekontraBool, ktoraGra, ktoKontraktI); + int wpadki = ileWpadek(); + int zebraneLewy = ILOSC_LEW - wpadki; - // Lewy Deklarowane - if(atut == TREFL_ID || atut == KARO_ID) - { - print("kontrakt TREFL lub KARO kazda karta kontraktowa za 20"); - punktyZaLew = 20; - if(kontraBool) - { - print("kontra TREFL lub KARO, kazda karta kontraktowa za 40"); - punktyZaLew = 40; - } - if(rekontraBool) - { - print("rekontra TREFL lub KARO, kazda karta kontraktowa za 80"); - punktyZaLew = 80; - } - - std::cout << "Ilosc lew w kontrakcie: " << lwy << " do punktow dodaje sie " << lwy * punktyZaLew << std::endl; - sumaPunktow += (lwy * punktyZaLew); - } - - if(atut == KIER_ID || atut == PIK_ID) - { - print("kontrakt KIER lub PIK, kazda kontraktowa 30"); - punktyZaLew = 30; - if(kontraBool) - { - print("kontra KIER lub PIK, kazda kontraktowa za 60"); - punktyZaLew = 60; - } - if(rekontraBool) - { - print("rekontra KIER lub PIK, kazda kontraktowa za 120"); - punktyZaLew = 120; - } - - std::cout << "Ilosc lew w kontrakcie: " << lwy << " do punktow dodaje sie " << lwy * punktyZaLew << std::endl; - sumaPunktow += (lwy * punktyZaLew); - } - - if(atut == BEZ_ATUTU_ID) - { - punktyZaLew = 30; - print("kontrakt BEZ_ATUTU, pierwsza lewa za 40, kazda nastepna za 30"); - sumaPunktow = 40; - if(kontraBool) - { - print("kontrakt BEZ_ATUTU, pierwsza lewa za 80, kazda nastepna za 60"); - sumaPunktow = 80; - punktyZaLew = 60; - } - if(rekontraBool) - { - print("kontrakt BEZ_ATUTU, pierwsza lewa za 160, kazda nastepna za 120"); - sumaPunktow = 160; - punktyZaLew = 120; - } - sumaPunktow += ( (lwy - 1) * punktyZaLew); - } - - bool czyRozgrywajacyPoPartii = ( ( (ktoraGra % CYKL_PO_PARTII) - 1) == ktoKontraktI || ktoraGra % CYKL_PO_PARTII == 3); - - if(lwy == SZLEMIK) - { - if(czyRozgrywajacyPoPartii) sumaPunktow += 750; - else sumaPunktow += 500; - } - - if(lwy == SZLEM) - { - if(czyRozgrywajacyPoPartii) sumaPunktow += 1500; - else sumaPunktow += 1000; - } - - - - bool dograna = (sumaPunktow >= 100); - if(dograna) - { - if(czyRozgrywajacyPoPartii) sumaPunktow += 500; - else sumaPunktow += 300; - }else sumaPunktow += 50; - - // Nadrobki - - if(!kontraBool && !rekontraBool) - { - int punktyZaNadrobki = punktyZaLew; - sumaPunktow += nadrobki * punktyZaNadrobki; - } - if(kontraBool && !rekontraBool) - { - int punktyZaNadrobki = 100; - if(czyRozgrywajacyPoPartii) punktyZaNadrobki = 200; - sumaPunktow += nadrobki * punktyZaNadrobki; - } - - if(kontraBool && rekontraBool) - { - - int punktyZaNadrobki = 200; - if(czyRozgrywajacyPoPartii) punktyZaNadrobki = 400; - sumaPunktow += nadrobki * punktyZaNadrobki; - } - - if(kontraBool && !rekontraBool) sumaPunktow += 50; - - if(kontraBool && rekontraBool) sumaPunktow += 100; - std::cout << "Rozgrywajacy zdobyl: " << sumaPunktow << std::endl; - if(ktoKontraktI == A_ID) - { - punktyA.push_back(sumaPunktow); - punktyB.push_back(0); - } - else - { - punktyB.push_back(sumaPunktow); - punktyA.push_back(0); - } - return; - }else - { - int zebraneLewy = ILOSC_LEW - wpadki; - int lewyWpadkowe = (lwy + DOMYSLNE_LEWY) - zebraneLewy; - int sumaPunktow = 0; - bool broniacyPoPartii = ( ((ktoraGra % CYKL_PO_PARTII) - 1) == !ktoKontraktI || ktoraGra % CYKL_PO_PARTII == 3); - if(broniacyPoPartii) - { - - if(!kontraBool && !rekontraBool) - { - sumaPunktow = 100; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 100; - else sumaPunktow += 0; - } - } - - if(kontraBool && !rekontraBool) - { - sumaPunktow = 200; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 300; - else sumaPunktow += 0; - } - } - - if(kontraBool && rekontraBool) - { - sumaPunktow = 400; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 600; - else sumaPunktow += 0; - } - } - }else - { - if(!kontraBool && !rekontraBool) - { - sumaPunktow = 50; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 50; - else sumaPunktow += 0; - } - } - - if(kontraBool && !rekontraBool) - { - sumaPunktow = 100; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 200; - else sumaPunktow += 100; - } - } - - if(kontraBool && rekontraBool) - { - sumaPunktow = 200; - for(int i = 1; i < lewyWpadkowe; i++) - { - if(i < 4) sumaPunktow += 400; - else sumaPunktow += 200; - } - } - } - std::cout << "Broniacy zdobyli: " << sumaPunktow << std::endl; - if(ktoKontraktI == A_ID) - { - punktyB.push_back(sumaPunktow); - punktyA.push_back(0); - } - else - { - punktyA.push_back(sumaPunktow); - punktyB.push_back(0); - } - return; - - } + bool rozgrywajacyWygral = 1; + if (zebraneLewy >= lwy + DOMYSLNE_LEWY) + rozgrywajacyWygral = 1; + else + rozgrywajacyWygral = 0; + punkty(punktyA, punktyB, lwy, atut, kontraBool, rekontraBool, ktoraGra, + ktoKontraktI, rozgrywajacyWygral, wpadki); + print("Czy koniec gry? 1 - TAK, 0 - NIE"); + std::cin >> koniecGry; + } while (!koniecGry); + tabela(punktyA, punktyB); + return 0; } - -bool gra() -{ - bool koniecGry = 0; - std::vector punktyA; - std::vector punktyB; - do{ - int ktoraGra = 0; - tabela(punktyA, punktyB); - int ktoKontraktI = ktoKontrakt(); - int lwy = zagraneLwy(); - int atut = zagranyAtut(lwy); - bool kontraBool = zagranaKontra(); - bool rekontraBool = 0; - if(kontraBool) rekontraBool = zagranaRekontra(); - stanGry(lwy, atut, kontraBool, rekontraBool, ktoraGra, ktoKontraktI); - int wpadki = ileWpadek(); - int zebraneLewy = ILOSC_LEW - wpadki; - - bool rozgrywajacyWygral = 1; - if( zebraneLewy >= lwy + DOMYSLNE_LEWY) rozgrywajacyWygral = 1; - else rozgrywajacyWygral = 0; - punkty(punktyA, punktyB, lwy, atut, kontraBool, rekontraBool, ktoraGra, ktoKontraktI, rozgrywajacyWygral, wpadki); - print("Czy koniec gry? 1 - TAK, 0 - NIE"); - std::cin >> koniecGry; - }while(!koniecGry); - tabela(punktyA, punktyB); - return 0; -} - -int main() -{ - while(gra()); - return 0; +int main() { + while (gra()) + ; + return 0; } diff --git a/CPP/miscelanious/calculateShotsDarts/basic.cpp b/CPP/miscelanious/calculateShotsDarts/basic.cpp index e41c8b0..bc7c383 100644 --- a/CPP/miscelanious/calculateShotsDarts/basic.cpp +++ b/CPP/miscelanious/calculateShotsDarts/basic.cpp @@ -1,91 +1,72 @@ #ifndef BASIC_CPP #define BASIC_CPP +#include #include #include -#include #include void print(const std::string s) { std::cout << s << std::endl; } -void printErrorStringContainsNotNumber(const std::string s) -{ - std::cout << "string: \"" << s - << "\" contains character different than number " << std::endl; +void printErrorStringContainsNotNumber(const std::string s) { + std::cout << "string: \"" << s + << "\" contains character different than number " << std::endl; } -void printNumberTooLow(const int number, const int min) -{ - std::cout << "number: " << number - << " is too low. Minimal number is: " << min << std::endl; +void printNumberTooLow(const int number, const int min) { + std::cout << "number: " << number << " is too low. Minimal number is: " << min + << std::endl; } -void printNumberTooHigh(const int number, const int max) -{ - std::cout << "number: " << number - << " is too high. Maximal number is: " << max << std::endl; +void printNumberTooHigh(const int number, const int max) { + std::cout << "number: " << number + << " is too high. Maximal number is: " << max << std::endl; } -void printNotValidStringLength(const std::string s, const int desiredLength) -{ - std::cout << "String: \"" << s << "\" is too short/too long, it is: " - << s.length() << " characters long but should be: " << desiredLength - << " characters long " << std::endl; +void printNotValidStringLength(const std::string s, const int desiredLength) { + std::cout << "String: \"" << s + << "\" is too short/too long, it is: " << s.length() + << " characters long but should be: " << desiredLength + << " characters long " << std::endl; } -void printInvalidCharacter(const char c, const char desiredCharacter) -{ - std::cout << "[ " << c << " ] Is invalid character, expected: [ " - << desiredCharacter << " ]" << std::endl; +void printInvalidCharacter(const char c, const char desiredCharacter) { + std::cout << "[ " << c << " ] Is invalid character, expected: [ " + << desiredCharacter << " ]" << std::endl; } -void printContainsIllegalCharacter( const std::string s, - const char illegalCharacter ) -{ - std::cout << "String: " << s << " consists of illegal sign: [" - << illegalCharacter << "]!" << std::endl; +void printContainsIllegalCharacter(const std::string s, + const char illegalCharacter) { + std::cout << "String: " << s << " consists of illegal sign: [" + << illegalCharacter << "]!" << std::endl; } - -bool numberTooLow(const int number, const int min) -{ - if(number < min) - { - printNumberTooLow(number, min); - return 1; - } - return 0; +bool numberTooLow(const int number, const int min) { + if (number < min) { + printNumberTooLow(number, min); + return 1; + } + return 0; } -bool numberTooHigh(const int number, const int max) -{ - if(number > max) - { - printNumberTooHigh(number, max); - return 1; - } - return 0; +bool numberTooHigh(const int number, const int max) { + if (number > max) { + printNumberTooHigh(number, max); + return 1; + } + return 0; } -bool containsIllegalCharacter(const std::string s, const char illegalCharacter) -{ - if( s.find(illegalCharacter) != std::string::npos) - { - printContainsIllegalCharacter(s, illegalCharacter); - return 1; - } - return 0; +bool containsIllegalCharacter(const std::string s, + const char illegalCharacter) { + if (s.find(illegalCharacter) != std::string::npos) { + printContainsIllegalCharacter(s, illegalCharacter); + return 1; + } + return 0; } +void e() { print("Poor man breakboint"); } -void e() -{ - print("Poor man breakboint"); -} - - -bool charIsNumber(const char c) -{ - return c >= '0' && c <= '9'; -} +bool charIsNumber(const char c) { return c >= '0' && c <= '9'; } #endif diff --git a/CPP/miscelanious/calculateShotsDarts/main.cpp b/CPP/miscelanious/calculateShotsDarts/main.cpp index 2834c11..61f5eba 100644 --- a/CPP/miscelanious/calculateShotsDarts/main.cpp +++ b/CPP/miscelanious/calculateShotsDarts/main.cpp @@ -1,89 +1,79 @@ #ifndef MAIN_CPP #define MAIN_CPP +#include "basic.cpp" #include #include #include -#include "basic.cpp" -std::vector fillVector(const int min, const int max) -{ - std::vector newVector; - for(int i = min; i <= max; i++) - { - newVector.push_back(i); - } - return newVector; +std::vector fillVector(const int min, const int max) { + std::vector newVector; + for (int i = min; i <= max; i++) { + newVector.push_back(i); + } + return newVector; } const int MAX_SPOT = 20; const int MIN_SPOT = 1; -const std::vector NORMAL_POINTS = fillVector(MIN_SPOT, MAX_SPOT); +const std::vector NORMAL_POINTS = fillVector(MIN_SPOT, MAX_SPOT); -std::vector multiplyVector(const std::vector v, int multiplyBy) -{ - std::vector newVector; - for(unsigned int i = 0; i < v.size(); i++) - { - newVector.push_back(v.at(i)*multiplyBy); - } - return newVector; +std::vector multiplyVector(const std::vector v, int multiplyBy) { + std::vector newVector; + for (unsigned int i = 0; i < v.size(); i++) { + newVector.push_back(v.at(i) * multiplyBy); + } + return newVector; } -const std::vector DOUBLE_POINTS = multiplyVector(NORMAL_POINTS, 2); -const std::vector TRIPLE_POINTS = multiplyVector(NORMAL_POINTS, 3); +const std::vector DOUBLE_POINTS = multiplyVector(NORMAL_POINTS, 2); +const std::vector TRIPLE_POINTS = multiplyVector(NORMAL_POINTS, 3); const int MAX_ONE_HIT = TRIPLE_POINTS.at(TRIPLE_POINTS.size() - 1); const int THROWS_IN_ONE_HIT = 3; const int MAX_POINTS_TURN = THROWS_IN_ONE_HIT * MAX_ONE_HIT; const int STARTING_POINTS = 501; const int FINAL_POINTS = 0; - -bool validString(const std::string s) -{ - for(unsigned int i = 0; i < s.length(); i++) - { - if(!charIsNumber(s.at(i))) - { - printErrorStringContainsNotNumber(s); - return 0; - } - } - return 1; +bool validString(const std::string s) { + for (unsigned int i = 0; i < s.length(); i++) { + if (!charIsNumber(s.at(i))) { + printErrorStringContainsNotNumber(s); + return 0; + } + } + return 1; } -bool validNumberInput(const std::string input, const int min, const int max) -{ - if(!validString(input)) return 0; - int inputInt = std::stoi(input); - if(numberTooLow(inputInt, min)) return 0; - if(numberTooHigh(inputInt, max)) return 0; - return 1; +bool validNumberInput(const std::string input, const int min, const int max) { + if (!validString(input)) + return 0; + int inputInt = std::stoi(input); + if (numberTooLow(inputInt, min)) + return 0; + if (numberTooHigh(inputInt, max)) + return 0; + return 1; } -bool validInput(const std::string s) -{ - if(s.length() > 3) return 0; - if(!validNumberInput(s, FINAL_POINTS, STARTING_POINTS)) return 0; - return 1; +bool validInput(const std::string s) { + if (s.length() > 3) + return 0; + if (!validNumberInput(s, FINAL_POINTS, STARTING_POINTS)) + return 0; + return 1; } -std::vector requiredShoots(const int pointsLeft) -{ +std::vector requiredShoots(const int pointsLeft) {} -} - - -int main() -{ - print("Enter points left: "); - std::string pointsLeft; - do{ - getline(std::cin, pointsLeft); - }while(!validInput(pointsLeft)); - int pointsLeftInt = std::stoi(pointsLeft); - requiredShoots(pointsLeftInt); - return 0; +int main() { + print("Enter points left: "); + std::string pointsLeft; + do { + getline(std::cin, pointsLeft); + } while (!validInput(pointsLeft)); + int pointsLeftInt = std::stoi(pointsLeft); + requiredShoots(pointsLeftInt); + return 0; } #endif diff --git a/CPP/miscelanious/findIntegerPercentageValue/main.cpp b/CPP/miscelanious/findIntegerPercentageValue/main.cpp index 0ff9355..444dc1f 100644 --- a/CPP/miscelanious/findIntegerPercentageValue/main.cpp +++ b/CPP/miscelanious/findIntegerPercentageValue/main.cpp @@ -1,60 +1,50 @@ -#include #include +#include const int PERCENTAGE = 44; const float PERCENTAGE_DENOMINATOR = 100; const int NUMBERS_TO_CHECK = 200; const bool DEBUG = 0; -bool isInteger(const float number) -{ - return number == std::floor(number); -} +bool isInteger(const float number) { return number == std::floor(number); } void printIsInteger(const int i, const int inputPercentage, - const float calculatedPercentage) -{ - std::cout << i << "*" << inputPercentage << "% is an integer number: " - << i*calculatedPercentage << std::endl; + const float calculatedPercentage) { + std::cout << i << "*" << inputPercentage + << "% is an integer number: " << i * calculatedPercentage + << std::endl; } -void printDebug(const int i, const float calculatedPercentage) -{ - std::cout << "i = " << i << std::endl; - std::cout << i*calculatedPercentage << std::endl; +void printDebug(const int i, const float calculatedPercentage) { + std::cout << "i = " << i << std::endl; + std::cout << i * calculatedPercentage << std::endl; } -void isIntegerLoop( const bool debugOn = DEBUG, - const int maxNumber = NUMBERS_TO_CHECK, - const int inputPercentage = PERCENTAGE ) -{ - float actualPercentage = inputPercentage / PERCENTAGE_DENOMINATOR; - for(int i = 1; i <= maxNumber; i++) - { - if(isInteger(i*actualPercentage)) - { - printIsInteger(i, inputPercentage, actualPercentage); - } - else if(debugOn) printDebug(i, actualPercentage); - } +void isIntegerLoop(const bool debugOn = DEBUG, + const int maxNumber = NUMBERS_TO_CHECK, + const int inputPercentage = PERCENTAGE) { + float actualPercentage = inputPercentage / PERCENTAGE_DENOMINATOR; + for (int i = 1; i <= maxNumber; i++) { + if (isInteger(i * actualPercentage)) { + printIsInteger(i, inputPercentage, actualPercentage); + } else if (debugOn) + printDebug(i, actualPercentage); + } } void printStartingMessage(const int maxNumber = NUMBERS_TO_CHECK, - const int inputPercentage = PERCENTAGE) -{ - std::cout << "For max number = " << maxNumber - << "; and a percentage: " << inputPercentage - << "; Found following integer numbers: " << std::endl; + const int inputPercentage = PERCENTAGE) { + std::cout << "For max number = " << maxNumber + << "; and a percentage: " << inputPercentage + << "; Found following integer numbers: " << std::endl; } -void mainFunctions() -{ - printStartingMessage(); - isIntegerLoop(); +void mainFunctions() { + printStartingMessage(); + isIntegerLoop(); } -int main() -{ - mainFunctions(); - return 0; +int main() { + mainFunctions(); + return 0; } diff --git a/CPP/miscelanious/howManyValidISBNNumbersAreThere/11.cpp b/CPP/miscelanious/howManyValidISBNNumbersAreThere/11.cpp index 2e0d8c6..9cbd0c4 100644 --- a/CPP/miscelanious/howManyValidISBNNumbersAreThere/11.cpp +++ b/CPP/miscelanious/howManyValidISBNNumbersAreThere/11.cpp @@ -1,133 +1,103 @@ -#include -#include -#include #include #include +#include +#include +#include #ifndef CHECK_ISBN_CPP #define CHECK_ISBN_CPP - const bool DEBUG = 0; const int ISBN_LENGTH = 10; const int CHECK_NUMBER = 11; const unsigned long long int HIGHEST_ISBN = 9999999999; - -void printVector(std::vector v) -{ - for(unsigned int i = 0; i < v.size(); i++) - { - std::cout << v[i] << "; "; - } +void printVector(std::vector v) { + for (unsigned int i = 0; i < v.size(); i++) { + std::cout << v[i] << "; "; + } } -void print(const std::string printMe) -{ - std::cout << printMe << std::endl; +void print(const std::string printMe) { std::cout << printMe << std::endl; } + +void e() { print("PRINT"); } + +bool checkInput(const std::string input) { + if (input.length() != ISBN_LENGTH) { + print("Your number is too short/too long"); + return 0; + } + for (int i = 0; i <= ISBN_LENGTH - 1; i++) { + if (input.at(i) < '0' || input.at(i) > '9') { + print("Your number consists of illegal characters"); + return 0; + } + } + return 1; } -void e() -{ - print("PRINT"); +std::vector stringToIntVector(const std::string input) { + std::vector vector; + for (int i = input.length() - 1; i >= 0; i--) { + vector.push_back(input.at(i) - '0'); + } + return vector; } -bool checkInput(const std::string input) -{ - if(input.length() != ISBN_LENGTH) - { - print("Your number is too short/too long"); - return 0; - } - for(int i = 0; i <= ISBN_LENGTH - 1; i++) - { - if(input.at(i) < '0' || input.at(i) > '9') - { - print("Your number consists of illegal characters"); - return 0; - } - } - return 1; +std::vector userISBN() { + std::string input; + do { + std::cout << "Enter the ISBN number (10 digits): "; + getline(std::cin, input); + } while (!checkInput(input)); + return stringToIntVector(input); } -std::vector stringToIntVector(const std::string input) -{ - std::vector vector; - for(int i = input.length() - 1; i >= 0; i--) - { - vector.push_back(input.at(i) - '0'); - } - return vector; +bool checkISBN(const std::vector isbn) { + int sum = 0, t = 0; + for (int i = 0; i < ISBN_LENGTH; i++) { + t += isbn[i]; + sum += t; + } + + /*if(DEBUG) + { + if(!(sum % CHECK_NUMBER)) print("^^^ VALID NUMBER ^^^"); + } */ + + return !(sum % CHECK_NUMBER); } -std::vector userISBN() -{ - std::string input; - do{ - std::cout << "Enter the ISBN number (10 digits): "; - getline(std::cin, input); - }while(!checkInput(input)); - return stringToIntVector(input); +std::vector intToVector(unsigned long long int number) { + std::vector numbers; + while (number > 0) { + numbers.push_back(number % 10); + number /= 10; + } + std::reverse(numbers.begin(), numbers.end()); + + return numbers; } - - - -bool checkISBN(const std::vector isbn) -{ - int sum = 0, t = 0; - for(int i = 0; i < ISBN_LENGTH; i++) - { - t += isbn[i]; - sum += t; - } - - /*if(DEBUG) - { - if(!(sum % CHECK_NUMBER)) print("^^^ VALID NUMBER ^^^"); - } */ - - return !(sum % CHECK_NUMBER); +int checkAll() { + int sum = 0; + std::ofstream file; + file.open("ISBN.txt"); + for (unsigned long long int i = HIGHEST_ISBN; i >= 1; i--) { + // if(DEBUG) std::cout << i << std::endl; + if (checkISBN(intToVector(i))) { + ++sum; + file << std::to_string(i) << "\n"; + } + } + file << "There are " << sum << " valid ISBN numbers\n"; + file.close(); + return sum; } -std::vector intToVector(unsigned long long int number) -{ - std::vector numbers; - while(number > 0) - { - numbers.push_back(number % 10); - number /= 10; - } - std::reverse(numbers.begin(), numbers.end()); - - return numbers; -} - - - -int checkAll() -{ - int sum = 0; - std::ofstream file; - file.open("ISBN.txt"); - for(unsigned long long int i = HIGHEST_ISBN; i >= 1; i--) - { - //if(DEBUG) std::cout << i << std::endl; - if( checkISBN(intToVector(i)) ) - { - ++sum; - file << std::to_string(i) << "\n"; - } - } - file << "There are " << sum << " valid ISBN numbers\n"; - file.close(); - return sum; -} - -int main() -{ - checkAll(); - return 0; +int main() { + checkAll(); + return 0; } #endif diff --git a/CPP/miscelanious/howOftenDoesCharOccur.cpp b/CPP/miscelanious/howOftenDoesCharOccur.cpp index 38877cc..d5c9e21 100644 --- a/CPP/miscelanious/howOftenDoesCharOccur.cpp +++ b/CPP/miscelanious/howOftenDoesCharOccur.cpp @@ -1,48 +1,39 @@ #include #include - -struct charOccurence -{ - char c; - int occurrence; +struct charOccurence { + char c; + int occurrence; }; -void printCharOccurenceVector(const std::vector v) -{ - std::cout << "["; - for(unsigned int i = 0; i < v.size(); i++) - { - std::cout << "(\"" << v.at(i).c << "\", " << v.at(i).occurrence << ")" << (i + 1 == v.size() ? "" : ", "); - } - std::cout << "]" << std::endl; - +void printCharOccurenceVector(const std::vector v) { + std::cout << "["; + for (unsigned int i = 0; i < v.size(); i++) { + std::cout << "(\"" << v.at(i).c << "\", " << v.at(i).occurrence << ")" + << (i + 1 == v.size() ? "" : ", "); + } + std::cout << "]" << std::endl; } +int main() { + std::vector list; + std::string userInput = "aaaabbbcca"; + charOccurence newCharOccurence; + newCharOccurence.c = userInput.at(0); + newCharOccurence.occurrence = 1; + for (unsigned int i = 1, j = 1; i < userInput.length(); i++) { + char newCharacter = userInput.at(i); + if (newCharacter != newCharOccurence.c) { + list.push_back(newCharOccurence); + j = 1; + newCharOccurence.c = newCharacter; + newCharOccurence.occurrence = j; -int main() -{ - std::vector list; - std::string userInput = "aaaabbbcca"; - charOccurence newCharOccurence; - newCharOccurence.c = userInput.at(0); - newCharOccurence.occurrence = 1; - for(unsigned int i = 1, j = 1; i < userInput.length(); i++) - { - char newCharacter = userInput.at(i); - if(newCharacter != newCharOccurence.c) - { - list.push_back(newCharOccurence); - j = 1; - newCharOccurence.c = newCharacter; - newCharOccurence.occurrence = j; - - }else - { - newCharOccurence.occurrence++; - } - } - list.push_back(newCharOccurence); - printCharOccurenceVector(list); - return 0; + } else { + newCharOccurence.occurrence++; + } + } + list.push_back(newCharOccurence); + printCharOccurenceVector(list); + return 0; } diff --git a/CPP/miscelanious/markovChainGenerator/basic.cpp b/CPP/miscelanious/markovChainGenerator/basic.cpp index 55072f0..fc88a1a 100644 --- a/CPP/miscelanious/markovChainGenerator/basic.cpp +++ b/CPP/miscelanious/markovChainGenerator/basic.cpp @@ -1,10 +1,10 @@ #ifndef BASIC_CPP #define BASIC_CPP +#include +#include #include #include -#include -#include void print(const std::string s) { std::cout << s << std::endl; } @@ -14,164 +14,136 @@ void e() { print("Poor man breakboint"); } bool charIsNumber(const char c) { return c >= '0' && c <= '9'; } -void printStringNewLine(const std::string s) -{ - std::cout << "string: " << std::endl; - std::cout << "\"" << s << "\"" << std::endl; +void printStringNewLine(const std::string s) { + std::cout << "string: " << std::endl; + std::cout << "\"" << s << "\"" << std::endl; } -void printStringContainsNotNumbers(const std::string s, const int position) -{ - printStringNewLine(s); - std::cout << "contains character different than number at position: " << position - << "; this character is: " << s.at(position) << std::endl; +void printStringContainsNotNumbers(const std::string s, const int position) { + printStringNewLine(s); + std::cout << "contains character different than number at position: " + << position << "; this character is: " << s.at(position) + << std::endl; } -void printStringContainsNumbers(const std::string s, const int position) -{ - printStringNewLine(s); - std::cout << "contains number at postion: " << position - << "; this number is: " << s.at(position) << std::endl; +void printStringContainsNumbers(const std::string s, const int position) { + printStringNewLine(s); + std::cout << "contains number at postion: " << position + << "; this number is: " << s.at(position) << std::endl; } -void printNumberTooLow(const int number, const int min) -{ - std::cout << "number: " << number - << " is too low. Minimal number is: " << min << std::endl; +void printNumberTooLow(const int number, const int min) { + std::cout << "number: " << number << " is too low. Minimal number is: " << min + << std::endl; } -void printNumberTooHigh(const int number, const int max) -{ - std::cout << "number: " << number - << " is too high. Maximal number is: " << max << std::endl; +void printNumberTooHigh(const int number, const int max) { + std::cout << "number: " << number + << " is too high. Maximal number is: " << max << std::endl; } -void printNotValidStringLength(const std::string s, const int desiredLength) -{ - printStringNewLine(s); - std::cout << "is too short/too long, it is: " - << s.length() << " characters long but should be: " << desiredLength - << " characters long " << std::endl; +void printNotValidStringLength(const std::string s, const int desiredLength) { + printStringNewLine(s); + std::cout << "is too short/too long, it is: " << s.length() + << " characters long but should be: " << desiredLength + << " characters long " << std::endl; } -void printInvalidCharacter(const char c, const char desiredCharacter) -{ - std::cout << "[ " << c << " ] Is invalid character, expected: [ " - << desiredCharacter << " ]" << std::endl; +void printInvalidCharacter(const char c, const char desiredCharacter) { + std::cout << "[ " << c << " ] Is invalid character, expected: [ " + << desiredCharacter << " ]" << std::endl; } -void printContainsIllegalCharacter( const std::string s, - const char illegalCharacter ) -{ - printStringNewLine(s); - std::cout << " consists of illegal sign: [" - << illegalCharacter << "]!" << std::endl; +void printContainsIllegalCharacter(const std::string s, + const char illegalCharacter) { + printStringNewLine(s); + std::cout << " consists of illegal sign: [" << illegalCharacter << "]!" + << std::endl; } - -bool numberTooLow(const int number, const int min) -{ - if(number < min) - { - printNumberTooLow(number, min); - return 1; - } - return 0; +bool numberTooLow(const int number, const int min) { + if (number < min) { + printNumberTooLow(number, min); + return 1; + } + return 0; } -bool numberTooHigh(const int number, const int max) -{ - if(number > max) - { - printNumberTooHigh(number, max); - return 1; - } - return 0; +bool numberTooHigh(const int number, const int max) { + if (number > max) { + printNumberTooHigh(number, max); + return 1; + } + return 0; } -bool containsIllegalCharacter(const std::string s, const char illegalCharacter) -{ - if( s.find(illegalCharacter) != std::string::npos) - { - printContainsIllegalCharacter(s, illegalCharacter); - return 1; - } - return 0; +bool containsIllegalCharacter(const std::string s, + const char illegalCharacter) { + if (s.find(illegalCharacter) != std::string::npos) { + printContainsIllegalCharacter(s, illegalCharacter); + return 1; + } + return 0; } -void printStringVector(const std::vector vector) -{ - for(unsigned int i = 0; i < vector.size(); i++) print(vector.at(i)); +void printStringVector(const std::vector vector) { + for (unsigned int i = 0; i < vector.size(); i++) + print(vector.at(i)); } -bool stringContainsNotNumbers(const std::string s) -{ - for(unsigned int i = 0; i < s.length(); i++) - { - if(!charIsNumber(s.at(i))) - { - printStringContainsNotNumbers(s, i); - return 1; - } - } - return 0; +bool stringContainsNotNumbers(const std::string s) { + for (unsigned int i = 0; i < s.length(); i++) { + if (!charIsNumber(s.at(i))) { + printStringContainsNotNumbers(s, i); + return 1; + } + } + return 0; } -bool stringContainsNumbers(const std::string s) -{ - for(unsigned int i = 0; i < s.length(); i++) - { - if(charIsNumber(s.at(i))) - { - printStringContainsNumbers(s, i); - return 1; - } - } - return 0; +bool stringContainsNumbers(const std::string s) { + for (unsigned int i = 0; i < s.length(); i++) { + if (charIsNumber(s.at(i))) { + printStringContainsNumbers(s, i); + return 1; + } + } + return 0; } -bool validStringLength(const std::string s, const int desiredLength) -{ - int stringLength = s.length(); - if(stringLength != desiredLength) - { - printNotValidStringLength(s, desiredLength); - return 0; - } - return 1; +bool validStringLength(const std::string s, const int desiredLength) { + int stringLength = s.length(); + if (stringLength != desiredLength) { + printNotValidStringLength(s, desiredLength); + return 0; + } + return 1; } -bool validCharacter(const char inputC, const char desiredC) -{ - if(inputC != desiredC) - { - printInvalidCharacter(inputC, desiredC); - return 0; - } - return 1; +bool validCharacter(const char inputC, const char desiredC) { + if (inputC != desiredC) { + printInvalidCharacter(inputC, desiredC); + return 0; + } + return 1; } -void vectorToFile(const std::vector strings, std::ofstream &file) -{ - for(unsigned int i = 0; i < strings.size(); i++) - { - file << strings.at(i) << std::endl; - } +void vectorToFile(const std::vector strings, std::ofstream &file) { + for (unsigned int i = 0; i < strings.size(); i++) { + file << strings.at(i) << std::endl; + } } -std::vector fileToVector(std::ifstream &file, - std::vector strings) -{ - std::string line; - if(file.is_open()) - { - while(getline(file, line)) - { - strings.push_back(line); - } - file.close(); - } - return strings; +std::vector fileToVector(std::ifstream &file, + std::vector strings) { + std::string line; + if (file.is_open()) { + while (getline(file, line)) { + strings.push_back(line); + } + file.close(); + } + return strings; } #endif diff --git a/CPP/miscelanious/markovChainGenerator/main.cpp b/CPP/miscelanious/markovChainGenerator/main.cpp index 15f2036..6a87674 100644 --- a/CPP/miscelanious/markovChainGenerator/main.cpp +++ b/CPP/miscelanious/markovChainGenerator/main.cpp @@ -1,138 +1,124 @@ #ifndef MAIN_CPP #define MAIN_CPP -#include -#include -#include #include "basic.cpp" +#include +#include +#include -struct wordOccurences -{ - std::string word; - int occurences; +struct wordOccurences { + std::string word; + int occurences; } -struct previousWords -{ - std::string word; - std::vector previousWords; +struct previousWords { + std::string word; + std::vector previousWords; }; -struct wordProbabiliy -{ - std::string previousWord; - std::string nextWord; - float probability; +struct wordProbabiliy { + std::string previousWord; + std::string nextWord; + float probability; } bool validInput(const std::string userInput) { - if(stringContainsNumbers(userInput)) return 0; - return 1; + if (stringContainsNumbers(userInput)) + return 0; + return 1; } -std::vector divideIntoWords(const std::string userInput) -{ - std::vector words; - int inputLength = userInput.length(); - int wordLength = 0; - for(int i = 0; i < inputLength; i++) - { - if(userInput.at(i) == ' ') - { - words.push_back(userInput.substr(i - wordLength, wordLength)); - wordLength = 0; - }else wordLength++; +std::vector divideIntoWords(const std::string userInput) { + std::vector words; + int inputLength = userInput.length(); + int wordLength = 0; + for (int i = 0; i < inputLength; i++) { + if (userInput.at(i) == ' ') { + words.push_back(userInput.substr(i - wordLength, wordLength)); + wordLength = 0; + } else + wordLength++; - if(i + 1 == inputLength) - { - words.push_back(userInput.substr(i - wordLength + 1, wordLength + 1)); - wordLength = 0; - } - } - return words; + if (i + 1 == inputLength) { + words.push_back(userInput.substr(i - wordLength + 1, wordLength + 1)); + wordLength = 0; + } + } + return words; } -int wordRepeats(const std::vector wordsList, const std::string word) -{ - int wordsSize = wordsList.size(); - for(int i = 0; i < wordsSize; i++) - { - if(wordsList.at(i).word == word) return i; - } - return -1; +int wordRepeats(const std::vector wordsList, + const std::string word) { + int wordsSize = wordsList.size(); + for (int i = 0; i < wordsSize; i++) { + if (wordsList.at(i).word == word) + return i; + } + return -1; } -bool alreadyExists(const std::vector wordsList, const std::string s) -{ - for(unsigned int i = 0; i < wordsList.size(); i++) - { - if(s == wordsList.previousWOrds - } +bool alreadyExists(const std::vector wordsList, + const std::string s) { + for (unsigned int i = 0; i < wordsList.size(); i++) { + if(s == wordsList.previousWOrds + } } -std::vector getWordsAndTheirPrevious(const std::vector words) -{ - std::vector wordsList; - int wordsSize = words.size(); - for(int i = 1; i < wordsSize; i++) - { - previousWords temp; - temp.word = words.at(i); - wordOccurences tempTwo; - tempTwo.word = words.at(i - 1)); - tempTwo.occurences = 1; - temp.previousWords.push_back(tempTwo); - int position = wordRepeats(wordsList, temp.word); - if(position == -1) - { - wordsList.push_back(temp); - }else - { +std::vector +getWordsAndTheirPrevious(const std::vector words) { + std::vector wordsList; + int wordsSize = words.size(); + for (int i = 1; i < wordsSize; i++) { + previousWords temp; + temp.word = words.at(i); + wordOccurences tempTwo; + tempTwo.word = words.at(i - 1)); + tempTwo.occurences = 1; + temp.previousWords.push_back(tempTwo); + int position = wordRepeats(wordsList, temp.word); + if (position == -1) { + wordsList.push_back(temp); + } else { - wordsList.at(position).previousWords.push_back(temp.previousWords.at(0)); - } - } - return wordsList; + wordsList.at(position).previousWords.push_back( + temp.previousWords.at(0)); + } + } + return wordsList; } -void printPreviousWord(const previousWords word) -{ - std::cout << "The word is \"" << word.word << "\" Words before it are: " << std::endl; - for(unsigned int i = 0; i < word.previousWords.size(); i++) - { - print(word.previousWords.at(i)); - } +void printPreviousWord(const previousWords word) { + std::cout << "The word is \"" << word.word + << "\" Words before it are: " << std::endl; + for (unsigned int i = 0; i < word.previousWords.size(); i++) { + print(word.previousWords.at(i)); + } } - -void printPreviousWordsVector(const std::vector v) -{ - for(unsigned int i = 0; i < v.size(); i++) - { - printPreviousWord(v.at(i)); - } +void printPreviousWordsVector(const std::vector v) { + for (unsigned int i = 0; i < v.size(); i++) { + printPreviousWord(v.at(i)); + } } -std::vector getWordProbability(const std::vector wordsList) -{ - std::vector probalityVector; - for(unsigned int i = 0; i - 1 < wordsList.size(); i++) - { - pro - } +std::vector +getWordProbability(const std::vector wordsList) { + std::vector probalityVector; + for (unsigned int i = 0; i - 1 < wordsList.size(); i++) { + pro + } } -int main() -{ - std::string userInput; - do{ - getline(std::cin, userInput); - }while(!validInput(userInput)); - std::vector words = divideIntoWords(userInput); - std::vector prev = getWordsAndTheirPrevious(words); - printPreviousWordsVector(prev); - return 0; +int main() { + std::string userInput; + do { + getline(std::cin, userInput); + } while (!validInput(userInput)); + std::vector words = divideIntoWords(userInput); + std::vector prev = getWordsAndTheirPrevious(words); + printPreviousWordsVector(prev); + return 0; } #endif diff --git a/CPP/miscelanious/mutiplicationWithoutStar/multiplication.cpp b/CPP/miscelanious/mutiplicationWithoutStar/multiplication.cpp index 8c0bc0b..31f84a3 100644 --- a/CPP/miscelanious/mutiplicationWithoutStar/multiplication.cpp +++ b/CPP/miscelanious/mutiplicationWithoutStar/multiplication.cpp @@ -1,27 +1,23 @@ #include - -int multiplication(int a, int b) -{ - int answer = 0; - for(int i = 0; i < a; i++) - { - answer += b; - } - if(answer != a*b) - { - std::cout << "There is a mistake in your code!" << std::endl; - return -1; - } else return answer; +int multiplication(int a, int b) { + int answer = 0; + for (int i = 0; i < a; i++) { + answer += b; + } + if (answer != a * b) { + std::cout << "There is a mistake in your code!" << std::endl; + return -1; + } else + return answer; } -int main() -{ - int a,b; - std::cout << "Enter number a" << std::endl; - std::cin >> a; - std::cout << "Enter number b" << std::endl; - std::cin >> b; - std::cout << multiplication(a, b) << std::endl; - return 0; +int main() { + int a, b; + std::cout << "Enter number a" << std::endl; + std::cin >> a; + std::cout << "Enter number b" << std::endl; + std::cin >> b; + std::cout << multiplication(a, b) << std::endl; + return 0; } diff --git a/CPP/miscelanious/quickchallenges.cpp b/CPP/miscelanious/quickchallenges.cpp index f0ab290..3bdb9f9 100644 --- a/CPP/miscelanious/quickchallenges.cpp +++ b/CPP/miscelanious/quickchallenges.cpp @@ -1,96 +1,99 @@ #include #include -int sumStartEnd(int start, int end) -{ - int sum = 0; - for(int i = start; i <= end; i++) - { - sum += i; - } - return sum; +int sumStartEnd(int start, int end) { + int sum = 0; + for (int i = start; i <= end; i++) { + sum += i; + } + return sum; } -int main() -{ - std::cout << "Krzysztof" << std::endl; - for(int i = 700; i >= 200; i -= 13) std::cout << i << std::endl; - std::vector array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - // if SECOND means 0, 1, TWO - std::cout << array[2] << std::endl; - // if SECOND means 1, TWO - std::cout << array[1] << std::endl; - std::cout << sumStartEnd(0, 1000); +int main() { + std::cout << "Krzysztof" << std::endl; + for (int i = 700; i >= 200; i -= 13) + std::cout << i << std::endl; + std::vector array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + // if SECOND means 0, 1, TWO + std::cout << array[2] << std::endl; + // if SECOND means 1, TWO + std::cout << array[1] << std::endl; + std::cout << sumStartEnd(0, 1000); - std::string userName; - std::cout << std::endl; - getline(std::cin, userName); - if(userName == "Jack") std::cout << "Hi Jack!" << std::endl; - else std::cout << "Hello, " << userName << std::endl; + std::string userName; + std::cout << std::endl; + getline(std::cin, userName); + if (userName == "Jack") + std::cout << "Hi Jack!" << std::endl; + else + std::cout << "Hello, " << userName << std::endl; - for(int i = 0; i <= 100; i++) - { - if(i % 2 == 0) std::cout << i << " is an even number" << std::endl; - else std::cout << i << " is an odd number" << std::endl; - } + for (int i = 0; i <= 100; i++) { + if (i % 2 == 0) + std::cout << i << " is an even number" << std::endl; + else + std::cout << i << " is an odd number" << std::endl; + } - bool flag = 1; - for(int i = 0; i <= 100; i++) - { - if(flag) std::cout << i << " is an even number" << std::endl; - else std::cout << i << " is an odd number" << std::endl; - flag = -flag; - } + bool flag = 1; + for (int i = 0; i <= 100; i++) { + if (flag) + std::cout << i << " is an even number" << std::endl; + else + std::cout << i << " is an odd number" << std::endl; + flag = -flag; + } - for(int i = 0; i <= 100; i += 2) std::cout << i << " is an even number " << std::endl; - for(int i = 1; i <= 99; i += 2) std::cout << i << " is an odd number " << std::endl; + for (int i = 0; i <= 100; i += 2) + std::cout << i << " is an even number " << std::endl; + for (int i = 1; i <= 99; i += 2) + std::cout << i << " is an odd number " << std::endl; - for(int i = 1, j = 1; j <= 12; i++) - { - std::cout << i * j << " "; + for (int i = 1, j = 1; j <= 12; i++) { + std::cout << i * j << " "; - if(i == 12) - { - i = 1; - j++; - std::cout << std::endl; - } - } + if (i == 12) { + i = 1; + j++; + std::cout << std::endl; + } + } - std::cout << std::endl; - std::string sentence; - getline(std::cin, sentence); - std::vector words; - std::string temp; - for(unsigned int i = 0; i < sentence.length(); i++) - { - if(sentence.at(i) == ' ' || i + 1 == sentence.length()) - { - if(i + 1 == sentence.length()) temp.push_back(sentence.at(i)); - words.push_back(temp); - temp = ""; - }else temp.push_back(sentence.at(i)); - - } - - for(unsigned int i = 0; i < words.size(); i++) - { - std::cout << words[i] << std::endl; - } - - int score; - char project; - std::vector GRADES = {'F', 'C', 'B', 'A'}; - std::cin >> score; - std::cout << std::endl; - std::cin >> project; - std::cout << std::endl; - bool doneProject = 0; - if(project == 'Y') doneProject = 1; - if(score < 50) std::cout << GRADES[0 + doneProject]; - else if(score < 70) std::cout << GRADES[1 + doneProject]; - else if(score < 90) std::cout << GRADES[2 + doneProject]; - else std::cout << GRADES[3]; + std::cout << std::endl; + std::string sentence; + getline(std::cin, sentence); + std::vector words; + std::string temp; + for (unsigned int i = 0; i < sentence.length(); i++) { + if (sentence.at(i) == ' ' || i + 1 == sentence.length()) { + if (i + 1 == sentence.length()) + temp.push_back(sentence.at(i)); + words.push_back(temp); + temp = ""; + } else + temp.push_back(sentence.at(i)); + } + for (unsigned int i = 0; i < words.size(); i++) { + std::cout << words[i] << std::endl; + } + int score; + char project; + std::vector GRADES = {'F', 'C', 'B', 'A'}; + std::cin >> score; + std::cout << std::endl; + std::cin >> project; + std::cout << std::endl; + bool doneProject = 0; + if (project == 'Y') + doneProject = 1; + if (score < 50) + std::cout << GRADES[0 + doneProject]; + else if (score < 70) + std::cout << GRADES[1 + doneProject]; + else if (score < 90) + std::cout << GRADES[2 + doneProject]; + else + std::cout << GRADES[3]; } diff --git a/CPP/miscelanious/randomDevice/main.cpp b/CPP/miscelanious/randomDevice/main.cpp index 6213e5c..7a27bb1 100644 --- a/CPP/miscelanious/randomDevice/main.cpp +++ b/CPP/miscelanious/randomDevice/main.cpp @@ -1,10 +1,10 @@ -#include #include +#include int main() { - std::random_device rd; - std::uniform_real_distribution dist(1.0, 10.0); + std::random_device rd; + std::uniform_real_distribution dist(1.0, 10.0); - for (int i=0; i<16; ++i) - std::cout << dist(rd) << "\n"; + for (int i = 0; i < 16; ++i) + std::cout << dist(rd) << "\n"; } diff --git a/CPP/miscelanious/reverseString.cpp b/CPP/miscelanious/reverseString.cpp index 34e4810..41316cb 100644 --- a/CPP/miscelanious/reverseString.cpp +++ b/CPP/miscelanious/reverseString.cpp @@ -1,22 +1,20 @@ +#include #include #include -#include -int main() -{ - std::string userString; - getline(std::cin, userString); - int sLength = userString.length(); - std::string tempString = userString; - for(int i = 0; i < sLength/2; i++) - { - char temp = tempString[sLength - 1 - i]; - tempString[sLength - 1 - i] = tempString[i]; - tempString[i] = temp; - } - reverse(userString.begin(), userString.end()); - bool correct = tempString == userString; - std::cout << correct << std::endl; - std::cout << tempString << std::endl; - return 0; +int main() { + std::string userString; + getline(std::cin, userString); + int sLength = userString.length(); + std::string tempString = userString; + for (int i = 0; i < sLength / 2; i++) { + char temp = tempString[sLength - 1 - i]; + tempString[sLength - 1 - i] = tempString[i]; + tempString[i] = temp; + } + reverse(userString.begin(), userString.end()); + bool correct = tempString == userString; + std::cout << correct << std::endl; + std::cout << tempString << std::endl; + return 0; } diff --git a/CPP/miscelanious/solveQuadraticEquation.cpp b/CPP/miscelanious/solveQuadraticEquation.cpp index 56195ba..b5183c4 100644 --- a/CPP/miscelanious/solveQuadraticEquation.cpp +++ b/CPP/miscelanious/solveQuadraticEquation.cpp @@ -1,48 +1,39 @@ #include -#include #include +#include const std::string ENTER = "Enter quadratic equation constants: "; const std::string WHAT_TO_INPUT = "a, b, c as in: ax^2 + bx + c = 0"; -const std::string START = ENTER + WHAT_TO_INPUT; +const std::string START = ENTER + WHAT_TO_INPUT; void print(const std::string s) { std::cout << s << std::endl; } -float getDelta(float a, float b, float c) -{ - return b*b - 4*a*c; +float getDelta(float a, float b, float c) { return b * b - 4 * a * c; } + +float calculateFirstTerm(float a, float b, float delta) { + return (-b - sqrt(delta)) / (2 * a); } -float calculateFirstTerm(float a, float b, float delta) -{ - return (-b - sqrt(delta))/(2*a); +float calculateSecondTerm(float a, float b, float delta) { + return (-b + sqrt(delta)) / (2 * a); } -float calculateSecondTerm(float a, float b, float delta) -{ - return (-b + sqrt(delta))/(2*a); -} - -int main() -{ - print(START); - float a, b, c; - std::cin >> a; - std::cin >> b; - std::cin >> c; - float delta = getDelta(a, b, c); - if(delta < 0) - { - print("delta smaller than 0"); - return -1; - } - - float x_1 = calculateFirstTerm(a, b, delta); - float x_2 = calculateSecondTerm(a, b, delta); - print("Solutions:"); - std::cout << "x_1 = " << x_1 << std::endl; - std::cout << "x_2 = " << x_2 << std::endl; - return 0; - - +int main() { + print(START); + float a, b, c; + std::cin >> a; + std::cin >> b; + std::cin >> c; + float delta = getDelta(a, b, c); + if (delta < 0) { + print("delta smaller than 0"); + return -1; + } + + float x_1 = calculateFirstTerm(a, b, delta); + float x_2 = calculateSecondTerm(a, b, delta); + print("Solutions:"); + std::cout << "x_1 = " << x_1 << std::endl; + std::cout << "x_2 = " << x_2 << std::endl; + return 0; } diff --git a/CPP/miscelanious/tictactoe/tictactoe.cpp b/CPP/miscelanious/tictactoe/tictactoe.cpp index 4583dc3..cb96494 100644 --- a/CPP/miscelanious/tictactoe/tictactoe.cpp +++ b/CPP/miscelanious/tictactoe/tictactoe.cpp @@ -1,111 +1,123 @@ #include #include -void printField(std::vector &field) -{ - std::cout << std::endl; - for(int i = 0; i < 9; i++) - { - if(i % 3 == 0) std::cout << std::endl; - if(field[i] == 0) std::cout << "-"; - else if(field[i] == 1) std::cout << "X"; - else if(field[i] == 2) std::cout << "O"; - } - std::cout << std::endl; +void printField(std::vector &field) { + std::cout << std::endl; + for (int i = 0; i < 9; i++) { + if (i % 3 == 0) + std::cout << std::endl; + if (field[i] == 0) + std::cout << "-"; + else if (field[i] == 1) + std::cout << "X"; + else if (field[i] == 2) + std::cout << "O"; + } + std::cout << std::endl; } - -unsigned int chooseField(unsigned int playerNumber, std::vector &field) -{ - unsigned int chosenField; - do - { - std::cout << "player " << playerNumber << " choose a field:" << std::endl; - std::cin >> chosenField; - }while(field[chosenField] != 0); - return chosenField; +unsigned int chooseField(unsigned int playerNumber, + std::vector &field) { + unsigned int chosenField; + do { + std::cout << "player " << playerNumber << " choose a field:" << std::endl; + std::cin >> chosenField; + } while (field[chosenField] != 0); + return chosenField; } -bool vertical(unsigned int playerNumber, std::vector &field) -{ - if((field[0] == playerNumber && field[1] == playerNumber && field[2] == playerNumber) - || (field[3] == playerNumber && field[4] == playerNumber && field[5] == playerNumber) - || (field[6] == playerNumber && field[7] == playerNumber && field[8] == playerNumber)) - { - return 1; - }else return 0; -} - -bool horizontal(unsigned int playerNumber, std::vector &field) -{ - if((field[0] == playerNumber && field[3] == playerNumber && field[6] == playerNumber) - || (field[1] == playerNumber && field[4] == playerNumber && field[7] == playerNumber) - || (field[2] == playerNumber && field[5] == playerNumber && field[8] == playerNumber)) - { - return 1; - }else return 0; -} - -bool across(unsigned int playerNumber, std::vector &field) -{ - if((field[0] == playerNumber && field[4] == playerNumber && field[8] == playerNumber) - || (field[2] == playerNumber && field[4] == playerNumber && field[6] == playerNumber)) - { - return 1; - }else return 0; -} - -bool checkPlayerWin(unsigned int playerNumber, std::vector &field) -{ - if(vertical(playerNumber, field)) return 1; - if(horizontal(playerNumber, field)) return 1; - if(across(playerNumber, field)) return 1; - else return 0; -} - -unsigned int checkIfWin(std::vector &field) -{ - if(checkPlayerWin(1, field)) return 1; - else if(checkPlayerWin(2, field)) return 2; - else return 0; -} - -bool checkIfFilled(std::vector &field) -{ - bool filled = 1; - for(int i = 0; i < 9; i++) - { - if(field[i] == 0) - { - filled = 0; - return filled; - } - } - return filled; -} - -bool turn(unsigned int playerNumber, std::vector &field, bool *filled, unsigned int *whoWon) -{ - field[chooseField(playerNumber, field)] = playerNumber; - printField(field); - *whoWon = checkIfWin(field); - *filled = checkIfFilled(field); - if(*whoWon != 0 || *filled != 0) return 1; - else return 0; -} - -int main() -{ - std::vector field = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - unsigned int whoWon = 0; - bool filled = 0; - - while(whoWon == 0 || filled == 0) - { - if(turn(1, field, &filled, &whoWon)) break; - if(turn(2, field, &filled, &whoWon)) break; - } - if(!filled) std::cout << "Player " << whoWon << " Won!" << std::endl; - else std::cout << "DRAW!" << std::endl; +bool vertical(unsigned int playerNumber, std::vector &field) { + if ((field[0] == playerNumber && field[1] == playerNumber && + field[2] == playerNumber) || + (field[3] == playerNumber && field[4] == playerNumber && + field[5] == playerNumber) || + (field[6] == playerNumber && field[7] == playerNumber && + field[8] == playerNumber)) { + return 1; + } else return 0; } + +bool horizontal(unsigned int playerNumber, std::vector &field) { + if ((field[0] == playerNumber && field[3] == playerNumber && + field[6] == playerNumber) || + (field[1] == playerNumber && field[4] == playerNumber && + field[7] == playerNumber) || + (field[2] == playerNumber && field[5] == playerNumber && + field[8] == playerNumber)) { + return 1; + } else + return 0; +} + +bool across(unsigned int playerNumber, std::vector &field) { + if ((field[0] == playerNumber && field[4] == playerNumber && + field[8] == playerNumber) || + (field[2] == playerNumber && field[4] == playerNumber && + field[6] == playerNumber)) { + return 1; + } else + return 0; +} + +bool checkPlayerWin(unsigned int playerNumber, + std::vector &field) { + if (vertical(playerNumber, field)) + return 1; + if (horizontal(playerNumber, field)) + return 1; + if (across(playerNumber, field)) + return 1; + else + return 0; +} + +unsigned int checkIfWin(std::vector &field) { + if (checkPlayerWin(1, field)) + return 1; + else if (checkPlayerWin(2, field)) + return 2; + else + return 0; +} + +bool checkIfFilled(std::vector &field) { + bool filled = 1; + for (int i = 0; i < 9; i++) { + if (field[i] == 0) { + filled = 0; + return filled; + } + } + return filled; +} + +bool turn(unsigned int playerNumber, std::vector &field, + bool *filled, unsigned int *whoWon) { + field[chooseField(playerNumber, field)] = playerNumber; + printField(field); + *whoWon = checkIfWin(field); + *filled = checkIfFilled(field); + if (*whoWon != 0 || *filled != 0) + return 1; + else + return 0; +} + +int main() { + std::vector field = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned int whoWon = 0; + bool filled = 0; + + while (whoWon == 0 || filled == 0) { + if (turn(1, field, &filled, &whoWon)) + break; + if (turn(2, field, &filled, &whoWon)) + break; + } + if (!filled) + std::cout << "Player " << whoWon << " Won!" << std::endl; + else + std::cout << "DRAW!" << std::endl; + return 0; +} diff --git a/CPP/miscelanious/tierListConverter/tierListConverter.cpp b/CPP/miscelanious/tierListConverter/tierListConverter.cpp index 03eb7ce..bbf9300 100644 --- a/CPP/miscelanious/tierListConverter/tierListConverter.cpp +++ b/CPP/miscelanious/tierListConverter/tierListConverter.cpp @@ -2,88 +2,74 @@ #include #include -const std::vector TIERS = {"Abhorrent", "Bad", "Mid", "Good", "Top", "God Tier"}; +const std::vector TIERS = {"Abhorrent", "Bad", "Mid", + "Good", "Top", "God Tier"}; const float TIER_BASE = TIERS.size(); -void print(std::string const s) -{ - std::cout << s << std::endl; +void print(std::string const s) { std::cout << s << std::endl; } + +bool errorUserInput(std::string userInput) { + if (userInput.find("/") == std::string::npos) { + print("No '/' was found!"); + return 1; + } + + size_t positionOfSlash = userInput.find("/"); + std::string nominatorS = userInput.substr(0, positionOfSlash); + + try { + float nominator = stof(nominatorS); + } catch (std::invalid_argument) { + print("No number was found before the slash!"); + return 1; + } + + std::string denominatorS = + userInput.substr(positionOfSlash + 1, userInput.length() - 1); + + try { + float denominator = stof(denominatorS); + if (denominator == 0) { + print("You cannot divide by 0!"); + return 1; + } + } catch (std::invalid_argument) { + print("No number was found after the slash!"); + return 1; + } + + return 0; } -bool errorUserInput(std::string userInput) -{ - if(userInput.find("/") == std::string::npos) - { - print("No '/' was found!"); - return 1; - } - - size_t positionOfSlash = userInput.find("/"); - std::string nominatorS = userInput.substr(0, positionOfSlash); - - try - { - float nominator = stof(nominatorS); - }catch ( std::invalid_argument ) - { - print("No number was found before the slash!"); - return 1; - } - - std::string denominatorS = userInput.substr(positionOfSlash + 1, userInput.length() - 1); - - try - { - float denominator = stof(denominatorS); - if(denominator == 0) - { - print("You cannot divide by 0!"); - return 1; - } - }catch ( std::invalid_argument ) - { - print("No number was found after the slash!"); - return 1; - } - - return 0; +std::string convertToTier(float nominator, float denominator) { + float fraction = nominator / denominator; + int tierIndex; + for (int i = TIER_BASE; i > 0; i--) { + if (fraction >= (i / TIER_BASE)) { + tierIndex = i - 1; + break; + } + } + if (tierIndex == 0 & fraction > (1.1 / 10.0)) + return TIERS[1]; + return TIERS[tierIndex]; } -std::string convertToTier(float nominator, float denominator) -{ - float fraction = nominator / denominator; - int tierIndex; - for(int i = TIER_BASE; i > 0; i--) - { - if(fraction >= ( i / TIER_BASE)) - { - tierIndex = i - 1; - break; - } - } - if(tierIndex == 0 & fraction > (1.1/10.0)) return TIERS[1]; - return TIERS[tierIndex]; -} - - -int main() -{ - std::string userScore; - do - { - print("Enter your score in a format: numberOne/numberTwo"); - getline(std::cin, userScore); - }while(errorUserInput(userScore)); - - size_t positionOfSlash = userScore.find("/"); - std::string nominatorS = userScore.substr(0, positionOfSlash); - - - float nominator = stof(nominatorS); - std::string denominatorS = userScore.substr(positionOfSlash + 1, userScore.length() - 1); - - - float denominator = stof(denominatorS); - print(convertToTier(nominator, denominator)); - return 0; +int main() { + std::string userScore; + do { + print("Enter your score in a format: numberOne/numberTwo"); + getline(std::cin, userScore); + } while (errorUserInput(userScore)); + + size_t positionOfSlash = userScore.find("/"); + std::string nominatorS = userScore.substr(0, positionOfSlash); + + float nominator = stof(nominatorS); + std::string denominatorS = + userScore.substr(positionOfSlash + 1, userScore.length() - 1); + + float denominator = stof(denominatorS); + print(convertToTier(nominator, denominator)); + return 0; } diff --git a/CPP/miscelanious/xGoesTo0/xgoes.cpp b/CPP/miscelanious/xGoesTo0/xgoes.cpp index 4253c21..9620a7a 100644 --- a/CPP/miscelanious/xGoesTo0/xgoes.cpp +++ b/CPP/miscelanious/xGoesTo0/xgoes.cpp @@ -1,11 +1,9 @@ #include -int main() -{ - int x = 10; - while (x-- > 0) - { - printf("%d;", x); - } - return 0; +int main() { + int x = 10; + while (x-- > 0) { + printf("%d;", x); + } + return 0; } diff --git a/CPP/miscelanious/yousuckatcards/Bernouli/bernouli.cpp b/CPP/miscelanious/yousuckatcards/Bernouli/bernouli.cpp index 674cd2c..27b4626 100644 --- a/CPP/miscelanious/yousuckatcards/Bernouli/bernouli.cpp +++ b/CPP/miscelanious/yousuckatcards/Bernouli/bernouli.cpp @@ -2,21 +2,22 @@ #include #include -int main() -{ - const int nrolls=10000; +int main() { + const int nrolls = 10000; - std::random_device rd; - std::mt19937 gen(rd()); - std::bernoulli_distribution distribution(0.5); + std::random_device rd; + std::mt19937 gen(rd()); + std::bernoulli_distribution distribution(0.5); - int count=0; // count number of trues + int count = 0; // count number of trues - for (int i=0; i #include +#include int main() { - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_real_distribution<> dis(0, 1); + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution<> dis(0, 1); - for(int i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { - std::cout << dis(gen) << std::endl; - }return 0; + std::cout << dis(gen) << std::endl; + } + return 0; } diff --git a/CPP/miscelanious/yousuckatcards/yousuckatcards.cpp b/CPP/miscelanious/yousuckatcards/yousuckatcards.cpp index e8ee143..22af25f 100644 --- a/CPP/miscelanious/yousuckatcards/yousuckatcards.cpp +++ b/CPP/miscelanious/yousuckatcards/yousuckatcards.cpp @@ -8,120 +8,117 @@ const bool BOT_WON = 0; const bool PLAYER_WON = 1; const int NOBODY_WON = 2; -void print(std::string const s) -{ - std::cout << s << std::endl; +void print(std::string const s) { std::cout << s << std::endl; } + +bool validSequence(std::string const s) { + if (s.size() != SEQUENCE_LENGTH) { + print("Sequence too long"); + return false; + } + if ((s[0] != 'B' && s[0] != 'R') || (s[1] != 'B' && s[1] != 'R') || + (s[2] != 'B' && s[2] != 'R')) { + print("Sequence consists of illegal signs!"); + return false; + } + return true; } -bool validSequence(std::string const s) -{ - if(s.size() != SEQUENCE_LENGTH) - { - print("Sequence too long"); - return false; - } - if( (s[0] != 'B' && s[0] != 'R') || - (s[1] != 'B' && s[1] != 'R') || - (s[2] != 'B' && s[2] != 'R')) - { - print("Sequence consists of illegal signs!"); - return false; - } - return true; +std::string playerChoice() { + std::string playerSequence; + do { + std::cin >> playerSequence; + } while (!validSequence(playerSequence)); + return playerSequence; } -std::string playerChoice() -{ +std::string botChoice(std::string const playerSequence) { + std::string botSequence; + if (playerSequence[1] == 'B') + botSequence.push_back('R'); + else + botSequence.push_back('B'); + botSequence.push_back(playerSequence[0]); + botSequence.push_back(playerSequence[2]); + return botSequence; +} + +int compareGeneratedAndPlayers(std::string playerSequence, + std::string botSequence, + std::string generatedSequence) { + int generatedSequenceLength = generatedSequence.length(); + std::string sequenceToCompare = generatedSequence.substr( + generatedSequenceLength - SEQUENCE_LENGTH, generatedSequenceLength); + if (sequenceToCompare.compare(playerSequence) == 0) + return PLAYER_WON; + if (sequenceToCompare.compare(botSequence) == 0) + return BOT_WON; + else + return NOBODY_WON; +} + +bool game(std::string playerSequence, std::string botSequence) { + std::string generatedSequence; + std::random_device rd; + std::mt19937 gen(rd()); + std::bernoulli_distribution distribution(0.5); + for (int i = 0; i < SEQUENCE_LENGTH; i++) { + if (distribution(gen)) + generatedSequence.push_back('R'); + else + generatedSequence.push_back('B'); + } + + while (compareGeneratedAndPlayers(playerSequence, botSequence, + generatedSequence) == NOBODY_WON) { + if (distribution(gen)) + generatedSequence.push_back('R'); + else + generatedSequence.push_back('B'); + } + + print(generatedSequence); + if (compareGeneratedAndPlayers(playerSequence, botSequence, + generatedSequence) == PLAYER_WON) + return PLAYER_WON; + else + return BOT_WON; +} + +void score(int playerWins, int botWins) { + std::cout << "Player won: " << playerWins << " times!" << std::endl; + std::cout << "Bot won: " << botWins << " times!" << std::endl; +} + +int main() { + int playerWins = 0; + int botWins = 0; + do { + print("Do you want to play the game? 1 - yes, 0 - no"); + bool continue_ = 1; + std::string playerInput; + std::cin >> playerInput; + if (playerInput[0] == '1') + continue_ = 1; + else + continue_ = 0; + if (!continue_) + break; std::string playerSequence; - do - { - std::cin >> playerSequence; + print("Write three colors sequence created from 52 cards from the deck (26 " + "Black, 26 Red), write B for Black and R for Red"); + playerSequence = playerChoice(); + std::string botSequence = botChoice(playerSequence); + print("Bot has chosen this sequence:"); + print(botSequence); + if (game(playerSequence, botSequence)) { + print("You won!"); + playerWins++; + score(playerWins, botWins); + } else { + print("Bot won!"); + botWins++; + score(playerWins, botWins); } - while(!validSequence(playerSequence)); - return playerSequence; -} - -std::string botChoice(std::string const playerSequence) -{ - std::string botSequence; - if(playerSequence[1] == 'B') botSequence.push_back('R'); - else botSequence.push_back('B'); - botSequence.push_back(playerSequence[0]); - botSequence.push_back(playerSequence[2]); - return botSequence; -} - -int compareGeneratedAndPlayers(std::string playerSequence, std::string botSequence, std::string generatedSequence) -{ - int generatedSequenceLength = generatedSequence.length(); - std::string sequenceToCompare = generatedSequence.substr(generatedSequenceLength - SEQUENCE_LENGTH, generatedSequenceLength); - if(sequenceToCompare.compare(playerSequence) == 0) return PLAYER_WON; - if(sequenceToCompare.compare(botSequence) == 0) return BOT_WON; - else return NOBODY_WON; -} - -bool game(std::string playerSequence, std::string botSequence) -{ - std::string generatedSequence; - std::random_device rd; - std::mt19937 gen(rd()); - std::bernoulli_distribution distribution(0.5); - for(int i = 0; i < SEQUENCE_LENGTH; i++) - { - if(distribution(gen)) generatedSequence.push_back('R'); - else generatedSequence.push_back('B'); - } - - while(compareGeneratedAndPlayers(playerSequence, botSequence, generatedSequence) == NOBODY_WON) - { - if(distribution(gen)) generatedSequence.push_back('R'); - else generatedSequence.push_back('B'); - } - - print(generatedSequence); - if(compareGeneratedAndPlayers(playerSequence, botSequence, generatedSequence) == PLAYER_WON) return PLAYER_WON; - else return BOT_WON; -} - -void score(int playerWins, int botWins) -{ - std::cout << "Player won: " << playerWins << " times!" << std::endl; - std::cout << "Bot won: " << botWins << " times!" << std::endl; -} - - - -int main() -{ - int playerWins = 0; - int botWins = 0; - do - { - print("Do you want to play the game? 1 - yes, 0 - no"); - bool continue_ = 1; - std::string playerInput; - std::cin >> playerInput; - if(playerInput[0] == '1') continue_ = 1; - else continue_ = 0; - if(!continue_) break; - std::string playerSequence; - print("Write three colors sequence created from 52 cards from the deck (26 Black, 26 Red), write B for Black and R for Red"); - playerSequence = playerChoice(); - std::string botSequence = botChoice(playerSequence); - print("Bot has chosen this sequence:"); - print(botSequence); - if(game(playerSequence, botSequence)) - { - print("You won!"); - playerWins++; - score(playerWins, botWins); - } - else - { - print("Bot won!"); - botWins++; - score(playerWins, botWins); - } - }while(1); - return 1; + } while (1); + return 1; } diff --git a/CPP/tests/howCppHandlesDivision.cpp b/CPP/tests/howCppHandlesDivision.cpp index 1e3f2d5..b16b0ce 100644 --- a/CPP/tests/howCppHandlesDivision.cpp +++ b/CPP/tests/howCppHandlesDivision.cpp @@ -1,8 +1,7 @@ #include -int main() -{ - float X = 1/2; - std::cout << X << std::endl; - return 0; +int main() { + float X = 1 / 2; + std::cout << X << std::endl; + return 0; } diff --git a/TS/battery-status/src/useBattery.ts b/TS/battery-status/src/useBattery.ts index 2668e73..77c2f74 100644 --- a/TS/battery-status/src/useBattery.ts +++ b/TS/battery-status/src/useBattery.ts @@ -83,8 +83,8 @@ export function useBattery() { } setLoading(false) - } catch (e: any) { - setError(e?.message ?? 'Failed to read battery status') + } catch (e: unknown) { + setError(e instanceof Error ? e.message : 'Failed to read battery status') setLoading(false) } } diff --git a/TS/champions_leauge_scores/server/src/server.ts b/TS/champions_leauge_scores/server/src/server.ts index 793b02a..f919fa1 100644 --- a/TS/champions_leauge_scores/server/src/server.ts +++ b/TS/champions_leauge_scores/server/src/server.ts @@ -10,7 +10,7 @@ const API_BASE = 'https://api.football-data.org/v4'; const API_TOKEN = process.env.FOOTBALL_DATA_API_KEY; if (!API_TOKEN) { - // eslint-disable-next-line no-console + console.warn('[server] FOOTBALL_DATA_API_KEY is not set. Live data will not work until you set it.'); } @@ -32,34 +32,40 @@ app.use((req, res, next) => { const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s); // Attach id so downstream handlers could use it if needed + // eslint-disable-next-line @typescript-eslint/no-explicit-any (res as any).locals = { ...(res as any).locals, requestId: id }; // Patch res.json and res.send to capture response payload const originalJson = res.json.bind(res); const originalSend = res.send.bind(res); - (res as any).json = (body: any) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (res as any).json = (body: unknown) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any try { (res as any).locals.bodyForLog = body; } catch { /* ignore */ } return originalJson(body); }; - (res as any).send = (body: any) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (res as any).send = (body: unknown) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any try { (res as any).locals.bodyForLog = body; } catch { /* ignore */ } - return originalSend(body as any); + return originalSend(body); }; - // eslint-disable-next-line no-console + console.log(`[#${id}] -> ${req.method} ${req.originalUrl}` + (Object.keys(req.query || {}).length ? ` query=${JSON.stringify(req.query)}` : '')); res.on('finish', () => { const durMs = Number(process.hrtime.bigint() - start) / 1_000_000; let bodyPreview = ''; try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const body = (res as any).locals?.bodyForLog; if (body !== undefined) { const str = typeof body === 'string' ? body : JSON.stringify(body); bodyPreview = ` body=${clip(str)}`; } } catch { /* ignore */ } - // eslint-disable-next-line no-console + console.log(`[#${id}] <- ${req.method} ${req.originalUrl} ${res.statusCode} ${durMs.toFixed(1)}ms${bodyPreview}`); }); @@ -69,13 +75,14 @@ app.use((req, res, next) => { // Axios interceptors to log outgoing requests and incoming responses axios.interceptors.request.use( (config) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (config as any).metadata = { start: Date.now() }; - // eslint-disable-next-line no-console + console.log(`[axios ->] ${String(config.method || 'GET').toUpperCase()} ${config.url}`); return config; }, (error) => { - // eslint-disable-next-line no-console + console.warn('[axios req error]', error?.message || error); return Promise.reject(error); } @@ -83,6 +90,7 @@ axios.interceptors.request.use( axios.interceptors.response.use( (response) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const started = (response.config as any).metadata?.start || Date.now(); const dur = Date.now() - started; let dataStr = ''; @@ -92,12 +100,13 @@ axios.interceptors.response.use( const size = dataStr?.length || 0; const MAX_LOG_BODY = 2000; const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s); - // eslint-disable-next-line no-console + console.log(`[axios <-] ${response.status} ${String(response.config.method || 'GET').toUpperCase()} ${response.config.url} ${dur}ms ~${size}B data=${clip(dataStr)}`); return response; }, (error) => { const cfg = error?.config || {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const started = (cfg as any).metadata?.start || Date.now(); const dur = Date.now() - started; const status = error?.response?.status; @@ -108,7 +117,7 @@ axios.interceptors.response.use( } catch { /* ignore */ } const MAX_LOG_BODY = 2000; const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s); - // eslint-disable-next-line no-console + console.warn(`[axios ! ] ${status ?? 'ERR'} ${String(cfg.method || 'GET').toUpperCase()} ${cfg.url} ${dur}ms data=${dataStr ? clip(dataStr) : (error?.message || 'error')}`); return Promise.reject(error); } @@ -122,7 +131,8 @@ function buildHeaders() { } as Record; } -function normalizeMatch(m: any) { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function normalizeMatch(m: Record) { return { id: m.id, utcDate: m.utcDate, @@ -135,7 +145,8 @@ function normalizeMatch(m: any) { score: m.score, competition: m.competition?.name || 'UEFA Champions League', venue: m.venue, - referees: m.referees?.map((r: any) => r.name).filter(Boolean) || [], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + referees: m.referees?.map((r: Record) => r.name).filter(Boolean) || [], }; } @@ -160,9 +171,10 @@ app.get('/api/live', async (_req: Request, res: Response) => { const { data } = await axios.get(url, { headers: buildHeaders(), params: { status: 'LIVE' } }); const matches = (data.matches || []).map(normalizeMatch); res.json({ count: matches.length, matches, fetchedAt: new Date().toISOString() }); - } catch (err: any) { - const status = err?.response?.status || 500; - res.status(status).json({ error: 'Failed to fetch live matches', details: err?.response?.data || err?.message }); + } catch (err: unknown) { + const axErr = err as { response?: { status?: number; data?: unknown }; message?: string }; + const status = axErr?.response?.status || 500; + res.status(status).json({ error: 'Failed to fetch live matches', details: axErr?.response?.data || axErr?.message }); } }); @@ -191,13 +203,14 @@ app.get('/api/matches', async (req: Request, res: Response) => { }); const matches = (data.matches || []).map(normalizeMatch); res.json({ count: matches.length, matches, fetchedAt: new Date().toISOString() }); - } catch (err: any) { - const status = err?.response?.status || 500; - res.status(status).json({ error: 'Failed to fetch matches', details: err?.response?.data || err?.message }); + } catch (err: unknown) { + const axErr = err as { response?: { status?: number; data?: unknown }; message?: string }; + const status = axErr?.response?.status || 500; + res.status(status).json({ error: 'Failed to fetch matches', details: axErr?.response?.data || axErr?.message }); } }); app.listen(PORT, () => { - // eslint-disable-next-line no-console + console.log(`[server] Listening on http://localhost:${PORT}`); }); diff --git a/TS/champions_leauge_scores/src/App.tsx b/TS/champions_leauge_scores/src/App.tsx index 2b0fe42..386d5b7 100644 --- a/TS/champions_leauge_scores/src/App.tsx +++ b/TS/champions_leauge_scores/src/App.tsx @@ -27,7 +27,7 @@ type ApiResponse = { fetchedAt: string; }; -function useFetchOnce(fn: () => Promise) { +function _useFetchOnce(fn: () => Promise) { const [data, setData] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(true); @@ -41,8 +41,8 @@ function useFetchOnce(fn: () => Promise) { setData(result); setError(null); } - } catch (e: any) { - if (mounted) setError(e?.message || 'Failed to fetch'); + } catch (e: unknown) { + if (mounted) setError(e instanceof Error ? e.message : 'Failed to fetch'); } finally { if (mounted) setLoading(false); } @@ -57,14 +57,13 @@ async function fetchJson(url: string, init?: RequestInit): Promise { const res = await fetch(url, { cache: 'no-store', ...init }); if (!res.ok) { const text = await res.text(); - let body: any = null; + let body: unknown = null; try { body = text ? JSON.parse(text) : null; } catch { /* noop */ } - const err: any = new Error(`HTTP ${res.status}`); - err.status = res.status; - err.body = body; + const err: { message: string; status: number; body: unknown; waitSec?: number } = { message: `HTTP ${res.status}`, status: res.status, body }; // Try to derive wait seconds for 429 from body.details.message like: "You reached your request limit. Wait 56 seconds." if (res.status === 429) { - const msg: string | undefined = body?.details?.message || body?.message || body?.error; + const details = body as Record | null; + const msg: string | undefined = (details?.message as string) || (details?.error as string) || (details?.details as Record)?.message as string | undefined; const m = msg ? msg.match(/(\d+)\s*seconds?/) : null; if (m) err.waitSec = Number(m[1]); } @@ -143,18 +142,19 @@ function useBackoffUntilSuccess(fn: () => Promise, opts?: { baseDelaySec?: clearTimers(); setData(result); setError(null); - } catch (e: any) { + } catch (e: unknown) { if (!mounted) return; + const httpErr = e as { status?: number; waitSec?: number; message?: string }; // 429: backoff and retry - if (e?.status === 429) { - const suggested = Number(e?.waitSec) || delayRef.current || base; + if (httpErr?.status === 429) { + const suggested = Number(httpErr?.waitSec) || delayRef.current || base; const next = Math.min(max, Math.max(base, suggested)); delayRef.current = Math.min(max, Math.ceil(next * factor)); setError(`Rate limited. Retrying in ${next}s...`); scheduleRetry(next); return; } - setError(e?.message || 'Failed to fetch'); + setError(httpErr?.message || 'Failed to fetch'); } finally { inFlightRef.current = false; if (mounted) setLoading(false); diff --git a/TS/two-inputs/src/app/app.component.ts b/TS/two-inputs/src/app/app.component.ts index 2db98d5..337d559 100644 --- a/TS/two-inputs/src/app/app.component.ts +++ b/TS/two-inputs/src/app/app.component.ts @@ -125,7 +125,7 @@ export class AppComponent { // Iterate through possible values of n1, which must be multiples of x, at least y, and not more than z for (let n1 = y; n1 <= ml - y && n1 <= z; n1 += x) { - let n2 = ml - n1; + const n2 = ml - n1; // Ensure n2 is also a multiple of x, n2 >= y, and n2 <= z if (n2 % x === 0 && n2 >= y && n2 <= z) { results.push([n1, n2]); diff --git a/articles/server_c.c b/articles/server_c.c index e9e784c..cb56c37 100644 --- a/articles/server_c.c +++ b/articles/server_c.c @@ -123,11 +123,28 @@ static size_t json_escaped_len(const char* s) { } static inline char* json_append_escaped(char* w, char c) { - if (c == '"' || c == '\\') { *w++ = '\\'; *w++ = c; return w; } - if (c == '\n') { *w++ = '\\'; *w++ = 'n'; return w; } - if (c == '\r') { *w++ = '\\'; *w++ = 'r'; return w; } - if (c == '\t') { *w++ = '\\'; *w++ = 't'; return w; } - *w++ = c; return w; + if (c == '"' || c == '\\') { + *w++ = '\\'; + *w++ = c; + return w; + } + if (c == '\n') { + *w++ = '\\'; + *w++ = 'n'; + return w; + } + if (c == '\r') { + *w++ = '\\'; + *w++ = 'r'; + return w; + } + if (c == '\t') { + *w++ = '\\'; + *w++ = 't'; + return w; + } + *w++ = c; + return w; } static void json_escape_into(char* out, const char* s) { @@ -164,12 +181,23 @@ static inline char json_unescape_char(char c) { } static void parse_json_string_core(const char* v, char* out, size_t* w, const char** after_end) { - bool esc = false; const char* p = v; + bool esc = false; + const char* p = v; for (; *p; ++p) { char c = *p; - if (esc) { out[(*w)++] = json_unescape_char(c); esc = false; continue; } - if (c == '\\') { esc = true; continue; } - if (c == '"') { *after_end = p + 1; break; } + if (esc) { + out[(*w)++] = json_unescape_char(c); + esc = false; + continue; + } + if (c == '\\') { + esc = true; + continue; + } + if (c == '"') { + *after_end = p + 1; + break; + } out[(*w)++] = c; } if (!*after_end) *after_end = p; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..250c0e0 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,29 @@ +// @ts-check +import eslint from "@eslint/js"; +import tseslint from "typescript-eslint"; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + files: ["TS/**/*.{ts,tsx}"], + }, + { + rules: { + "@typescript-eslint/no-unused-vars": [ + "error", + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, + ], + }, + }, + { + ignores: [ + "**/node_modules/**", + "**/dist/**", + "**/build/**", + "**/*.d.ts", + "**/*.config.ts", + "**/*.config.js", + ], + }, +); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..76a7130 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1473 @@ +{ + "name": "testsAndMisc", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@eslint/js": "^9.39.2", + "@types/node": "^25.3.0", + "eslint": "^9.39.2", + "typescript-eslint": "^8.56.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", + "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", + "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.2.tgz", + "integrity": "sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.7.tgz", + "integrity": "sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "25.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.0.tgz", + "integrity": "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.18.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.0.tgz", + "integrity": "sha512-lRyPDLzNCuae71A3t9NEINBiTn7swyOhvUj3MyUOxb8x6g6vPEFoOU+ZRmGMusNC3X3YMhqMIX7i8ShqhT74Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/type-utils": "8.56.0", + "@typescript-eslint/utils": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.56.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.56.0.tgz", + "integrity": "sha512-IgSWvLobTDOjnaxAfDTIHaECbkNlAlKv2j5SjpB2v7QHKv1FIfjwMy8FsDbVfDX/KjmCmYICcw7uGaXLhtsLNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.56.0.tgz", + "integrity": "sha512-M3rnyL1vIQOMeWxTWIW096/TtVP+8W3p/XnaFflhmcFp+U4zlxUxWj4XwNs6HbDeTtN4yun0GNTTDBw/SvufKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.56.0", + "@typescript-eslint/types": "^8.56.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.56.0.tgz", + "integrity": "sha512-7UiO/XwMHquH+ZzfVCfUNkIXlp/yQjjnlYUyYz7pfvlK3/EyyN6BK+emDmGNyQLBtLGaYrTAI6KOw8tFucWL2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.56.0.tgz", + "integrity": "sha512-bSJoIIt4o3lKXD3xmDh9chZcjCz5Lk8xS7Rxn+6l5/pKrDpkCwtQNQQwZ2qRPk7TkUYhrq3WPIHXOXlbXP0itg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.56.0.tgz", + "integrity": "sha512-qX2L3HWOU2nuDs6GzglBeuFXviDODreS58tLY/BALPC7iu3Fa+J7EOTwnX9PdNBxUI7Uh0ntP0YWGnxCkXzmfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0", + "@typescript-eslint/utils": "8.56.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.56.0.tgz", + "integrity": "sha512-DBsLPs3GsWhX5HylbP9HNG15U0bnwut55Lx12bHB9MpXxQ+R5GC8MwQe+N1UFXxAeQDvEsEDY6ZYwX03K7Z6HQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.56.0.tgz", + "integrity": "sha512-ex1nTUMWrseMltXUHmR2GAQ4d+WjkZCT4f+4bVsps8QEdh0vlBsaCokKTPlnqBFqqGaxilDNJG7b8dolW2m43Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.56.0", + "@typescript-eslint/tsconfig-utils": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/visitor-keys": "8.56.0", + "debug": "^4.4.3", + "minimatch": "^9.0.5", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.56.0.tgz", + "integrity": "sha512-RZ3Qsmi2nFGsS+n+kjLAYDPVlrzf7UhTffrDIKr+h2yzAlYP/y5ZulU0yeDEPItos2Ph46JAL5P/On3pe7kDIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.56.0", + "@typescript-eslint/types": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.56.0.tgz", + "integrity": "sha512-q+SL+b+05Ud6LbEE35qe4A99P+htKTKVbyiNEe45eCbJFyh/HVK9QXwlrbz+Q4L8SOW4roxSVwXYj4DMBT7Ieg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.56.0", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.0.tgz", + "integrity": "sha512-A0XeIi7CXU7nPlfHS9loMYEKxUaONu/hTEzHTGba9Huu94Cq1hPivf+DE5erJozZOky0LfvXAyrV/tcswpLI0Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/acorn": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", + "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.2.tgz", + "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.1", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.39.2", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/ts-api-utils": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", + "integrity": "sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.56.0.tgz", + "integrity": "sha512-c7toRLrotJ9oixgdW7liukZpsnq5CZ7PuKztubGYlNppuTqhIoWfhgHo/7EU0v06gS2l/x0i2NEFK1qMIf0rIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.56.0", + "@typescript-eslint/parser": "8.56.0", + "@typescript-eslint/typescript-estree": "8.56.0", + "@typescript-eslint/utils": "8.56.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/undici-types": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3ef349b --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "@eslint/js": "^9.39.2", + "@types/node": "^25.3.0", + "eslint": "^9.39.2", + "typescript-eslint": "^8.56.0" + } +} diff --git a/setup.sh b/setup.sh index 5f9131e..8768e24 100755 --- a/setup.sh +++ b/setup.sh @@ -11,4 +11,23 @@ printf 'Configuring git hooks path...\n' git config core.hooksPath linux_configuration/.githooks printf ' ✓ core.hooksPath set to linux_configuration/.githooks\n' -printf 'Setup complete.\n' +# Check for C/C++ and shell lint tools (used by pre-commit hooks) +MISSING=() +for cmd in clang-format cppcheck flawfinder shellcheck node npx; do + command -v "$cmd" >/dev/null 2>&1 || MISSING+=("$cmd") +done + +if [[ ${#MISSING[@]} -gt 0 ]]; then + printf '\n⚠ Missing tools for pre-commit hooks: %s\n' "${MISSING[*]}" + if command -v pacman >/dev/null 2>&1; then + printf ' Install with: sudo pacman -S --needed %s\n' "${MISSING[*]}" + elif command -v apt-get >/dev/null 2>&1; then + printf ' Install with: sudo apt-get install %s\n' "${MISSING[*]}" + else + printf ' Please install: %s\n' "${MISSING[*]}" + fi +else + printf ' ✓ All lint tools available\n' +fi + +printf '\nSetup complete.\n'