Skip to content

is it possible to contribute on this repository ? if yes then how? #1

Description

@mkhavari01
No description provided.

Activity

  1. jadijadi commented on Jul 30, 2023

    @jadijadi
    Owner

    I'm also figuring out :)
    My general idea is recording some videos to show how I code semi-simple functions / scripts to solve everyday life or simple questions. To give people who know the language, practices on simple problems. The questions might come from read world issues, CTFs, jobs, needs, questions, ....

  2. abzrgzdh commented on Aug 2, 2023

    @abzrgzdh
    Contributor

    can we contribute answers in different languages (e.g. solve.c for an answer in C)?

  3. abzrgzdh commented on Aug 2, 2023

    @abzrgzdh
    Contributor

    For example, here is my answer (inspired by yours) to strings/tfcctf2023-MAYDAY

    #include <stdio.h>
    #include <string.h>
    #include <stdbool.h>
    
    
    /*
       An interesting bug happend here when I set SPECIALS_MAX_KEY to 5.
    
       In that case
          token != specials[i].k 
       for the strings "Three", "Seven", and "Eight".
    
       That is because former is a pointer to an arbitrary sized array of chars (char *) ending with '\0' but
       the later is a strictly sized (5) character without '\0' (char c[5])
    */
    #define SPECIALS_MAX_KEY 6UL
    typedef struct {
        const char k[SPECIALS_MAX_KEY];
        char v;
    } specials_t;
    
    #define SPECIALS_SIZE (sizeof(specials) / sizeof(specials[0]))
    const specials_t specials[] = {
        { .k = "One",   .v = '1' },
        { .k = "Two",   .v = '2' },
        { .k = "Three", .v = '3' },
        { .k = "Four",  .v = '4' },
        { .k = "Five",  .v = '5' },
        { .k = "Six",   .v = '6' },
        { .k = "Seven", .v = '7' },
        { .k = "Eight", .v = '8' },
        { .k = "Nine",  .v = '9' },
        { .k = "Zero",  .v = '0' },
        { .k = "Dash",  .v = '-' }
    };
    
    
    #define DELIMITER " "
    
    
    bool find_special_token(const char* token, char* output) {
        for (size_t i = 0; i < SPECIALS_SIZE; i++) {
            if (strncmp(token, specials[i].k, SPECIALS_MAX_KEY) == 0) {
                *output = specials[i].v;
                return true;
            }
        }
        return false;
    }
    
    // ----<main>------------------------------------------------------------------
    
    int main(void)
    {
        char response[] = "Whiskey Hotel Four Tango Dash Alpha Romeo Three Dash"
                          " Yankee Oscar Uniform Dash Sierra One November Kilo"
                          " India November Golf Dash Four Bravo Zero Uniform Seven";
    
    
        char* token = strtok(response, DELIMITER);
    
        while (token != NULL) {
            char special_token = { 0 };
    
            if (find_special_token(token, &special_token)) {
                putchar(special_token);
            } else {
                putchar(token[0]);
            }
    
            token = strtok(NULL, DELIMITER);
        }
    
        printf("\n");
    
        return 0;
    }
  4. jadijadi commented on Aug 2, 2023

    @jadijadi
    Owner

    can we contribute answers in different languages (e.g. solve.c for an answer in C)?

    I think this is a good idea. I will check and accept

  5. jadijadi commented on Aug 2, 2023

    @jadijadi
    Owner

    For example, here is my answer (inspired by yours) to strings/tfcctf2023-MAYDAY

    #include <stdio.h>
    #include <string.h>
    #include <stdbool.h>
    
    
    /*
       An interesting bug happend here when I set SPECIALS_MAX_KEY to 5.
    
       In that case
          token != specials[i].k 
       for the strings "Three", "Seven", and "Eight".
    
       That is because former is a pointer to an arbitrary sized array of chars (char *) ending with '\0' but
       the later is a strictly sized (5) character without '\0' (char c[5])
    */
    #define SPECIALS_MAX_KEY 6UL
    typedef struct {
        const char k[SPECIALS_MAX_KEY];
        char v;
    } specials_t;
    
    #define SPECIALS_SIZE (sizeof(specials) / sizeof(specials[0]))
    const specials_t specials[] = {
        { .k = "One",   .v = '1' },
        { .k = "Two",   .v = '2' },
        { .k = "Three", .v = '3' },
        { .k = "Four",  .v = '4' },
        { .k = "Five",  .v = '5' },
        { .k = "Six",   .v = '6' },
        { .k = "Seven", .v = '7' },
        { .k = "Eight", .v = '8' },
        { .k = "Nine",  .v = '9' },
        { .k = "Zero",  .v = '0' },
        { .k = "Dash",  .v = '-' }
    };
    
    
    #define DELIMITER " "
    
    
    bool find_special_token(const char* token, char* output) {
        for (size_t i = 0; i < SPECIALS_SIZE; i++) {
            if (strncmp(token, specials[i].k, SPECIALS_MAX_KEY) == 0) {
                *output = specials[i].v;
                return true;
            }
        }
        return false;
    }
    
    // ----<main>------------------------------------------------------------------
    
    int main(void)
    {
        char response[] = "Whiskey Hotel Four Tango Dash Alpha Romeo Three Dash"
                          " Yankee Oscar Uniform Dash Sierra One November Kilo"
                          " India November Golf Dash Four Bravo Zero Uniform Seven";
    
    
        char* token = strtok(response, DELIMITER);
    
        while (token != NULL) {
            char special_token = { 0 };
    
            if (find_special_token(token, &special_token)) {
                putchar(special_token);
            } else {
                putchar(token[0]);
            }
    
            token = strtok(NULL, DELIMITER);
        }
    
        printf("\n");
    
        return 0;
    }

    So please open an RP, if not already done

  6. abzrgzdh commented on Aug 2, 2023

    @abzrgzdh
    Contributor

    So please open an RP, if not already done

    sure I'll do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions