├── 4-0-rev_wstr ├── a.out ├── examples.txt ├── subject.ro.txt ├── subject.en.txt ├── subject.fr.txt ├── rev_wstr.c └── rev_wstr2.c ├── images ├── level_0.png ├── level_1.png ├── level_2.png ├── level_3.png ├── level_4.png └── level_5.png ├── 0-1-maff_alpha ├── examples.txt ├── subject.fr.txt └── maff_alpha.c ├── 2-1-do_op ├── examples.txt ├── subject.fr.txt └── do_op.c ├── 3-0-ft_atoi_base ├── main.c ├── subject.en.txt ├── subject.fr.txt └── ft_atoi_base.c ├── 0-0-aff_first_param ├── examples.txt ├── aff_first_param.c ├── subject.en.txt └── subject.fr.txt ├── flood_fill ├── t_point.h ├── subject.en.txt └── subject.fr.txt ├── 0-1-only_z ├── subject.fr.txt └── only_z.c ├── 4-1-brainfuck ├── examples.txt ├── subject.en.txt ├── subject.ro.txt └── subject.fr.txt ├── brackets.c ├── 4-1-fprime ├── examples.txt ├── subject.en.txt ├── subject.ro.txt ├── subject.fr.txt └── fprime.c ├── 3-1-ft_strcpy ├── subject.en.txt ├── subject.ro.txt └── subject.fr.txt ├── 0-1-ft_countdown ├── subject.fr.txt ├── ft_countdown_easy.c └── ft_countdown.c ├── 2-1-ft_swap ├── subject.ro.txt ├── subject.en.txt ├── subject.fr.txt └── ft_swap.c ├── 0-0-ft_print_numbers ├── subject.fr.txt ├── ft_print_numbers_easy.c └── ft_print_numbers.c ├── 2-2-ft_strrev ├── subject.fr.txt └── ft_strrev.c ├── 4-1-ft_itoa ├── subject.en.txt ├── subject.fr.txt ├── subject.ro.txt └── ft_itoa.c ├── cycle_detector.c ├── 3-0-rstr_capitalizer ├── examples.txt ├── subject.en.txt ├── subject.ro.txt ├── subject.fr.txt └── rstr_capitalizer.c ├── 0-2-maff_revalpha ├── subject.fr.txt └── maff_revalpha.c ├── 0-2-strlen_sh ├── subject.en.txt ├── subject.fr.txt ├── strlen2.sh └── strlen.sh ├── 2-2-max ├── subject.en.txt ├── subject.ro.txt ├── subject.fr.txt └── max.c ├── 4-2-cycle_detector ├── cycle_detector.c └── list.h ├── 2-1-swap_bits ├── subject.fr.txt └── swap_bits.c ├── 1-0-rev_print ├── subject.fr.txt └── rev_print.c ├── 2-2-reverse_bits └── subject.fr.txt ├── 0-2-aff_last_param ├── subject.fr.txt ├── subject.en.txt └── aff_last_param.c ├── 4-0-ft_split ├── subject.fr.txt └── ft_split.c ├── 0-0-aff_a ├── subject.en.txt ├── subject.fr.txt └── aff_a.c ├── 3-0-add_prime_sum ├── subject.en.txt ├── subject.fr.txt ├── subject.ro.txt └── add_prime_sum.c ├── 4-0-check_mate ├── examples.txt ├── check_mate.c ├── subject.en.txt └── subject.fr.txt ├── 4-0-ft_list_remove_if ├── subject.ro.txt ├── subject.en.txt ├── subject.fr.txt └── ft_list_remove_if.c ├── 2-0-alpha_mirror ├── subject.fr.txt └── alpha_mirror.c ├── 3-0-ft_rrange ├── subject.en.txt ├── subject.fr.txt ├── subject.ro.txt └── ft_rrange.c ├── 5-0-print_memory ├── subject.ro.txt ├── subject.en.txt └── subject.fr.txt ├── 2-0-union ├── subject.fr.txt └── union.c ├── biggest_pal ├── subject.en.txt ├── subject.fr.txt └── biggest_pal.c ├── 3-0-lcm ├── subject.fr.txt └── lcm.c ├── 5-0-cycle_detector ├── subject.fr.txt ├── list.h ├── subject.en.txt └── cycle_detector.c ├── 0-0-only_a └── only_a.c ├── 4-0-sort_list ├── list.h ├── subject.en.txt ├── subject.fr.txt ├── subject.ro.txt └── sort_list.c ├── 4-0-moment ├── subject.en.txt ├── subject.fr.txt ├── moment_fail.c └── moment.c ├── 4-2-ft_list_foreach ├── ft_list.h └── ft_list_foreach.c ├── 5-0-brackets ├── subject.en.txt ├── subject.fr.txt └── brackets.c ├── 2-3-ft_strdup └── ft_strdup.c ├── options ├── subject.en.txt ├── subject.fr.txt └── options.c ├── 3-3-ft_range └── ft_range.c ├── 5-1-rpn_calc ├── subject.en.txt ├── rpn_calc.c └── subject.fr.txt ├── ft_itoa_base.c └── README.md /4-0-rev_wstr/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/4-0-rev_wstr/a.out -------------------------------------------------------------------------------- /images/level_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_0.png -------------------------------------------------------------------------------- /images/level_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_1.png -------------------------------------------------------------------------------- /images/level_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_2.png -------------------------------------------------------------------------------- /images/level_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_3.png -------------------------------------------------------------------------------- /images/level_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_4.png -------------------------------------------------------------------------------- /images/level_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsauva/exam/HEAD/images/level_5.png -------------------------------------------------------------------------------- /0-1-maff_alpha/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./maff_alpha | cat -e 2 | aBcDeFgHiJkLmNoPqRsTuVwXyZ$ 3 | -------------------------------------------------------------------------------- /2-1-do_op/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./do_op "123" "*" 456 | cat -e 2 | 56088$ 3 | $> ./do_op "9828" "/" 234 | cat -e 4 | 42$ 5 | $> ./do_op "1" "+" "-43" | cat -e 6 | -42$ 7 | $> ./do_op | cat -e 8 | $ 9 | -------------------------------------------------------------------------------- /3-0-ft_atoi_base/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **argv) 4 | { 5 | if (ac == 3) 6 | { 7 | printf("atoi base : %d\n", ft_atoi_base(av[1], atoi(av[2]))); 8 | } 9 | return (0); 10 | } 11 | -------------------------------------------------------------------------------- /0-0-aff_first_param/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./aff_first_param vincent mit "l'ane" dans un pre et "s'en" vint | cat -e 2 | vincent$ 3 | $> ./aff_first_param "j'aime le fromage de chevre" | cat -e 4 | j'aime le fromage de chevre$ 5 | $> ./aff_first_param 6 | $ 7 | -------------------------------------------------------------------------------- /flood_fill/t_point.h: -------------------------------------------------------------------------------- 1 | #ifndef T_POINT_FLOOD_FILL 2 | # define T_POINT_FLOOD_FILL 3 | 4 | typedef struct s_point { 5 | int x; // x : Width | x-axis 6 | int y; // y : Height | y-axis 7 | } t_point; 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /0-1-only_z/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : only_z 2 | Expected files : only_z.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui affiche un caractère 'z' sur la sortie standard. 7 | -------------------------------------------------------------------------------- /4-1-brainfuck/examples.txt: -------------------------------------------------------------------------------- 1 | $>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e 2 | Hello World!$ 3 | $>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e 4 | Hi$ 5 | $>./brainfuck | cat -e 6 | $ 7 | -------------------------------------------------------------------------------- /4-0-rev_wstr/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./rev_wstr "le temps du mepris precede celui de l'indifference" | cat -e 2 | l'indifference de celui precede mepris du temps le$ 3 | $> ./rev_wstr "abcdefghijklm" 4 | abcdefghijklm 5 | $> ./rev_wstr "il contempla le mont" | cat -e 6 | mont le contempla il$ 7 | $> ./rev_wstr | cat -e 8 | $ 9 | $> 10 | -------------------------------------------------------------------------------- /brackets.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int brackets(char *s) 4 | { 5 | int a = 0; 6 | int c = 0; 7 | int p = 0; 8 | char last; 9 | 10 | if (*s == '{') 11 | a++; 12 | if (*s == '[') 13 | c++; 14 | if (*s == '(') 15 | p++; 16 | if (*s == '}') 17 | { 18 | --a; 19 | if (last == '[' || last == '(') 20 | return (0); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /4-1-fprime/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./fprime 225225 | cat -e 2 | 3*3*5*5*7*11*13$ 3 | $> ./fprime 8333325 | cat -e 4 | 3*3*5*5*7*11*13*37$ 5 | $> ./fprime 9539 | cat -e 6 | 9539$ 7 | $> ./fprime 804577 | cat -e 8 | 804577$ 9 | $> ./fprime 42 | cat -e 10 | 2*3*7$ 11 | $> ./fprime 1 | cat -e 12 | 1$ 13 | $> ./fprime | cat -e 14 | $ 15 | $> ./fprime 42 21 | cat -e 16 | $ 17 | -------------------------------------------------------------------------------- /3-1-ft_strcpy/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strcpy 2 | Expected files : ft_strcpy.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Reproduce the behavior of the function strcpy (man strcpy). 7 | 8 | Your function must be declared as follows: 9 | 10 | char *ft_strcpy(char *s1, char *s2); 11 | -------------------------------------------------------------------------------- /3-1-ft_strcpy/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : ft_strcpy 2 | Fisiere de iesire : ft_strcpy.c 3 | Functii autorizate : 4 | -------------------------------------------------------------------------------- 5 | 6 | Reproduceti comportamentul functiei strcpy (man strcpy). 7 | 8 | Functia voastra va trebui sa aiba prototipul urmator: 9 | 10 | char *ft_strcpy(char *s1, char *s2); 11 | 12 | -------------------------------------------------------------------------------- /0-1-ft_countdown/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_countdown 2 | Expected files : ft_countdown.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui affiche tous les chiffres en ordre descendant, suivis 7 | d'un newline. 8 | 9 | Exemple: 10 | $> ./ft_countdown | cat -e 11 | 9876543210$ 12 | $> 13 | -------------------------------------------------------------------------------- /2-1-ft_swap/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : ft_swap 2 | Fisiere de iesire : ft_swap.c 3 | Functii autorizate : 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti o functie ce schimba valoarea a doi intregi ale caror adrese sunt 7 | transmise ca parametri. 8 | 9 | Ea trebuie sa aibaprototipul urmator: 10 | 11 | void ft_swap(int *a, int *b); 12 | 13 | -------------------------------------------------------------------------------- /2-1-ft_swap/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_swap 2 | Expected files : ft_swap.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that swaps the contents of two integers the adresses of which 7 | are passed as parameters. 8 | 9 | Your function must be declared as follows: 10 | 11 | void ft_swap(int *a, int *b); 12 | -------------------------------------------------------------------------------- /3-1-ft_strcpy/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strcpy 2 | Expected files : ft_strcpy.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Reproduisez à l'identique le comportement de la fonction strcpy (man strcpy). 7 | 8 | Votre fonction devra être prototypée de la façon suivante : 9 | 10 | char *ft_strcpy(char *s1, char *s2); 11 | -------------------------------------------------------------------------------- /0-0-ft_print_numbers/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_print_numbers 2 | Expected files : ft_print_numbers.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui affiche tous les chiffres dans l'ordre croissant. 7 | 8 | Elle devra être prototypée de la façon suivante : 9 | 10 | void ft_print_numbers(void); 11 | 12 | -------------------------------------------------------------------------------- /2-1-ft_swap/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_swap 2 | Expected files : ft_swap.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui échange le contenu de deux entiers dont les adresses 7 | sont passées en paramêtres. 8 | 9 | Elle devra être prototypée de la façon suivante : 10 | 11 | void ft_swap(int *a, int *b); 12 | -------------------------------------------------------------------------------- /0-0-aff_first_param/aff_first_param.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | 8 | void ft_putstr(char *str) 9 | { 10 | int i; 11 | 12 | i = 0; 13 | while (str[i]) 14 | { 15 | ft_putchar(str[i]); 16 | i++; 17 | } 18 | } 19 | 20 | int main(int ac, char **av) 21 | { 22 | if (ac > 1) 23 | { 24 | ft_putstr(av[1]); 25 | } 26 | ft_putchar('\n'); 27 | } 28 | -------------------------------------------------------------------------------- /2-2-ft_strrev/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strrev 2 | Expected files : ft_strrev.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui inverse (en place) une chaîne de caractères. 7 | 8 | Elle devra renvoyer son paramètre. 9 | 10 | Votre fonction devra être prototypée de la façon suivante : 11 | 12 | char *ft_strrev(char *str); 13 | -------------------------------------------------------------------------------- /0-1-maff_alpha/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : maff_alpha 2 | Expected files : maff_alpha.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui affiche l'alphabet une lettre sur 2 en minuscule, et le 7 | reste en majuscule (Voir l'exemple), suivi d'un '\n'. 8 | 9 | Exemple: 10 | 11 | $> ./maff_alpha | cat -e 12 | aBcDeFgHiJkLmNoPqRsTuVwXyZ$ 13 | -------------------------------------------------------------------------------- /4-1-ft_itoa/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_itoa 2 | Expected files : ft_itoa.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes an int and converts it to a null-terminated string. 7 | The function returns the result in a char array that you must allocate. 8 | 9 | Your function must be declared as follows: 10 | 11 | char *ft_itoa(int nbr); 12 | -------------------------------------------------------------------------------- /cycle_detector.c: -------------------------------------------------------------------------------- 1 | #include "list.h" 2 | 3 | int cycle_detector(const t_list *list) 4 | { 5 | if (list == NULL) 6 | return (1); 7 | const t_list *slow; 8 | const t_list *fast; 9 | 10 | while (1) 11 | { 12 | slow = slow->next; 13 | if (fast->next != NULL) 14 | fast = fast->next->next; 15 | else 16 | return (0); 17 | if (slow == NULL || fast == NULL) 18 | return (0); 19 | if (slow == fast) 20 | return (1); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /3-0-rstr_capitalizer/examples.txt: -------------------------------------------------------------------------------- 1 | $> ./rstr_capitalizer | cat -e 2 | $ 3 | $> ./rstr_capitalizer "Premier PETIT TesT" | cat -e 4 | premieR petiT tesT$ 5 | $> ./rstr_capitalizer "DeuxiEmE tEST uN PEU moinS facile" " attention C'EST pas dur QUAND mEmE" "ALLer UN DeRNier 0123456789pour LA rouTE E " | cat -e 6 | deuxiemE tesT uN peU moinS facilE$ 7 | attentioN c'esT paS duR quanD memE$ 8 | alleR uN dernieR 0123456789pouR lA routE E $ 9 | $> 10 | 11 | -------------------------------------------------------------------------------- /0-2-maff_revalpha/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : maff_revalpha 2 | Expected files : maff_revalpha.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui affiche l'alphabet à l'envers, une lettre sur 2 en 7 | minuscule, et le reste en majuscule (Voir l'exemple), suivi d'un '\n'. 8 | 9 | Exemple: 10 | 11 | $> ./maff_revalpha | cat -e 12 | zYxWvUtSrQpOnMlKjIhGfEdCbA$ 13 | -------------------------------------------------------------------------------- /0-2-strlen_sh/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : strlen_sh 2 | Expected files : strlen.sh 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a shell script that displays the length of the string contained in the 7 | environment variable FT_LINE, followed by a \n. 8 | 9 | Example: 10 | 11 | $> echo $FT_LINE 12 | Les stagiaires du staff ne sentent pas toujours tres bon. 13 | $> zsh strlen.sh 14 | 57 15 | $> 16 | -------------------------------------------------------------------------------- /4-1-ft_itoa/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_itoa 2 | Expected files : ft_itoa.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui prend un int et le convertit en chaîne terminée par un 7 | caractère nul. Cette fonction retourne le résultat en tant qu'un tableau de 8 | char que vous devez allouer. 9 | 10 | Votre fonction sera déclarée comme suit: 11 | 12 | char *ft_itoa(int nbr); 13 | -------------------------------------------------------------------------------- /4-1-ft_itoa/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_itoa 2 | Expected files : ft_itoa.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti o functie care primeste un int si il converteste intr-un sir de caractere, care se termina cu null. Functia returneaza resultatul intr-un vector de char pe care trebuie sa il alocati. 7 | 8 | Functia trebuie declarata ca si mai jos: 9 | 10 | char *ft_itoa(int nbr); 11 | -------------------------------------------------------------------------------- /0-2-strlen_sh/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : strlen_sh 2 | Expected files : strlen.sh 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un script shell qui affiche la longueur de la chaine de caractères 7 | présente dans la variable d'environnement FT_LINE, suivie d'un '\n'. 8 | 9 | Exemple: 10 | 11 | $> echo $FT_LINE 12 | Les stagiaires du staff ne sentent pas toujours tres bon. 13 | $> zsh strlen.sh 14 | 57 15 | $> 16 | -------------------------------------------------------------------------------- /2-2-max/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : max 2 | Expected files : max.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following function: 7 | 8 | int max(int* tab, unsigned int len); 9 | 10 | The first parameter is an array of int, the second is the number of elements in 11 | the array. 12 | 13 | The function returns the largest number found in the array. 14 | 15 | If the array is empty, the function returns 0. 16 | -------------------------------------------------------------------------------- /2-2-max/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : max 2 | Fisiere de iesire : max.c 3 | Functii autorizate : 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti functia urmatoare: 7 | 8 | int max(int* tab, unsigned int len); 9 | 10 | Primul parametru este un tablou de intregi, al doile este numarul de elemente 11 | continute in tablou. 12 | 13 | Functia trebuie sa returmeze cel mai mare numar gasit in tablou. 14 | 15 | Daca tabloul este vid, functia va returna 0. 16 | -------------------------------------------------------------------------------- /2-2-max/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : max 2 | Expected files : max.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire la fonction suivante: 7 | 8 | int max(int *tab, unsigned int len); 9 | 10 | Le premier paramètre est un tableau d'int, le deuxième est le nombre d'éléments 11 | contenus dans ce tableau. 12 | 13 | La fonction renvoie le plus grand nombre trouvé dans le tableau. 14 | 15 | Si le tableau est vide, la fonction renvoie 0. 16 | -------------------------------------------------------------------------------- /4-2-cycle_detector/cycle_detector.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "./list.h" 3 | 4 | int cycle_detector(const t_list *list) 5 | { 6 | if (list == NULL) 7 | return (1); 8 | const t_list *slow; 9 | const t_list *fast; 10 | 11 | slow = list; 12 | fast = list; 13 | while (1) 14 | { 15 | slow = slow->next; 16 | if (fast->next != NULL) 17 | fast = fast->next->next; 18 | else 19 | return (0); 20 | if (slow == NULL || fast == NULL) 21 | return (0); 22 | if (slow == fast) 23 | retrun (1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /2-1-swap_bits/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : swap_bits 2 | Expected files : swap_bits.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui prend un octet, inverse ses moitiés (comme dans l'exemple), puis retourne le résultat. 7 | 8 | Votre fonction doit être déclarée comme suit: 9 | 10 | unsigned char swap_bits(unsigned char octet); 11 | 12 | Exemple: 13 | 14 | 1 byte 15 | _____________ 16 | 0100 | 0001 17 | \ / 18 | / \ 19 | 0001 | 0100 20 | -------------------------------------------------------------------------------- /1-0-rev_print/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_print 2 | Expected files : rev_print.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend une chaîne et l'affiche en ordre inverse suivie 7 | d'un newline. 8 | 9 | Si le nombre d'arguments n'est pas 1, le programme affiche un newline. 10 | 11 | Exemples: 12 | 13 | $> ./rev_print "zaz" | cat -e 14 | zaz$ 15 | $> ./rev_print "dub0 a POIL" | cat -e 16 | LIOP a 0bud$ 17 | $> ./rev_print | cat -e 18 | $ 19 | -------------------------------------------------------------------------------- /2-2-reverse_bits/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : reverse_bits 2 | Expected files : reverse_bits.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui prend un octet, l'inverse bit à bit (comme dans 7 | l'exemple) et retourne le résultat. 8 | 9 | Votre fonction doit être déclarée comme suit: 10 | 11 | unsigned char reverse_bits(unsigned char octet); 12 | 13 | Exemple: 14 | 15 | 1 byte 16 | _____________ 17 | 0100 0001 18 | || 19 | \/ 20 | 1000 0010 21 | -------------------------------------------------------------------------------- /0-2-aff_last_param/subject.fr.txt: -------------------------------------------------------------------------------- 1 | ssignment name : aff_last_param 2 | Expected files : aff_last_param.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend des chaînes, et affiche son dernier argument suivi d'un newline. 7 | 8 | S'il y a moins d'un argument, le programme affiche juste un newline. 9 | 10 | Exemples: 11 | 12 | $> ./aff_last_param "zaz" "mange" "des" "chats" | cat -e 13 | chats$ 14 | $> ./aff_last_param "j'aime le savon" | cat -e 15 | j'aime le savon$ 16 | $> ./aff_last_param 17 | $ 18 | -------------------------------------------------------------------------------- /0-2-aff_last_param/subject.en.txt: -------------------------------------------------------------------------------- 1 | ssignment name : aff_last_param 2 | Expected files : aff_last_param.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes strings as arguments, and displays its last 7 | argument followed by a newline. 8 | 9 | If the number of arguments is less than 1, the program displays a newline. 10 | 11 | Examples: 12 | 13 | $> ./aff_last_param "zaz" "mange" "des" "chats" | cat -e 14 | chats$ 15 | $> ./aff_last_param "j'aime le savon" | cat -e 16 | j'aime le savon$ 17 | $> ./aff_last_param 18 | $ 19 | 20 | -------------------------------------------------------------------------------- /0-0-aff_first_param/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_first_param 2 | Expected files : aff_first_param.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes strings as arguments, and displays its first 7 | argument followed by a \n. 8 | 9 | If the number of arguments is less than 1, the program displays \n. 10 | 11 | Example: 12 | 13 | $> ./aff_first_param vincent mit "l'ane" dans un pre et "s'en" vint | cat -e 14 | vincent$ 15 | $> ./aff_first_param "j'aime le fromage de chevre" | cat -e 16 | j'aime le fromage de chevre$ 17 | $> ./aff_first_param 18 | $ 19 | -------------------------------------------------------------------------------- /4-0-ft_split/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_split 2 | Expected files : ft_split.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui prend en paramètre une chaîne de caractères et la 7 | découpe en mots, qui seront retournés sous la forme d'un tableau de chaînes 8 | terminé par NULL. 9 | 10 | On appelle "mot" une portion de chaîne de caractères délimitée soit par des 11 | espaces, des retours à la ligne et/ou des tabulations, soit par le début / fin 12 | de la chaîne. 13 | 14 | Votre fonction devra être prototypée de la façon suivante : 15 | 16 | char **ft_split(char *str); 17 | -------------------------------------------------------------------------------- /0-0-aff_a/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_a 2 | Expected files : aff_a.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string, and displays the first 'a' character it 7 | encounters in it, followed by a newline. If there are no 'a' characters in the 8 | string, the program just writes a newline. If the number of parameters is not 9 | 1, the program displays 'a' followed by a newline. 10 | 11 | Example: 12 | 13 | $> ./aff_a "abc" | cat -e 14 | a$ 15 | $> ./aff_a "dubO a POIL" | cat -e 16 | a$ 17 | $> ./aff_a "zz sent le poney" | cat -e 18 | $ 19 | $> ./aff_a | cat -e 20 | a$ 21 | -------------------------------------------------------------------------------- /0-0-aff_first_param/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_first_param 2 | Expected files : aff_first_param.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètre des chaînes de caractères, et qui 7 | affiche son premier paramètre suivi d'un '\n'. 8 | 9 | Si le nombre de paramètres est inférieur à 1, le programme affiche '\n'. 10 | 11 | Exemple: 12 | 13 | $> ./aff_first_param vincent mit "l'ane" dans un pre et "s'en" vint | cat -e 14 | vincent$ 15 | $> ./aff_first_param "j'aime le fromage de chevre" | cat -e 16 | j'aime le fromage de chevre$ 17 | $> ./aff_first_param 18 | $ 19 | -------------------------------------------------------------------------------- /3-0-add_prime_sum/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : add_prime_sum 2 | Expected files : add_prime_sum.c 3 | Allowed functions: write, exit 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a positive integer as argument and displays the sum 7 | of all prime numbers inferior or equal to it followed by a newline. 8 | 9 | If the number of arguments is not 1, or the argument is not a positive number, 10 | just display 0 followed by a newline. 11 | 12 | Yes, the examples are right. 13 | 14 | Examples: 15 | 16 | $>./add_prime_sum 5 17 | 10 18 | $>./add_prime_sum 7 | cat -e 19 | 17$ 20 | $>./add_prime_sum | cat -e 21 | 0$ 22 | $> 23 | -------------------------------------------------------------------------------- /3-0-add_prime_sum/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : add_prime_sum 2 | Expected files : add_prime_sum.c 3 | Allowed functions: write, exit 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend un entier positif en argument et affiche la somme 7 | de tous les nombres premiers inférieurs ou égaux à ce paramètre, suivie d'un 8 | \n. 9 | 10 | Si le nombre d'arguments n'est pas 1, ou que l'argument n'est pas positif, 11 | afficher 0 et un \n. 12 | 13 | Oui, les exemples sont justes. 14 | 15 | Exemples: 16 | 17 | $>./add_prime_sum 5 18 | 10 19 | $>./add_prime_sum 7 | cat -e 20 | 17$ 21 | $>./add_prime_sum | cat -e 22 | 0$ 23 | $> 24 | -------------------------------------------------------------------------------- /4-0-check_mate/examples.txt: -------------------------------------------------------------------------------- 1 | Pion / Pawn (P): 2 | 3 | . . . . . . . 4 | . . . . . . . 5 | . . X . X . . 6 | . . . P . . . 7 | . . . . . . . 8 | . . . . . . . 9 | . . . . . . . 10 | 11 | Fou / Bishop (B): 12 | 13 | X . . . . . X 14 | . X . . . X . 15 | . . X . X . . 16 | . . . B . . . 17 | . . X . X . . 18 | . X . . . X . 19 | X . . . . . X 20 | 21 | Tour / Rook (R): 22 | 23 | . . . X . . . 24 | . . . X . . . 25 | . . . X . . . 26 | X X X R X X X 27 | . . . X . . . 28 | . . . X . . . 29 | . . . X . . . 30 | 31 | Dame / Queen (Q) 32 | 33 | X . . X . . X 34 | . X . X . X . 35 | . . X X X . . 36 | X X X Q X X X 37 | . . X X X . . 38 | . X . X . X . 39 | X . . X . . X 40 | -------------------------------------------------------------------------------- /0-0-aff_a/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_a 2 | Expected files : aff_a.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend une chaîne de caractères et affiche le premier 7 | caractère 'a' qu'il y rencontre, suivi d'un newline. S'il n'y a pas de 8 | caractère 'a' dans la chaîne, le programme affiche juste un newline. Si le 9 | nombre de paramètres n'est pas 1, le programme affiche 'a' suivi d'un newline. 10 | 11 | Exemple: 12 | 13 | $> ./aff_a "abc" | cat -e 14 | a$ 15 | $> ./aff_a "dubO a POIL" | cat -e 16 | a$ 17 | $> ./aff_a "zz sent le poney" | cat -e 18 | $ 19 | $> ./aff_a | cat -e 20 | a$ 21 | -------------------------------------------------------------------------------- /3-0-add_prime_sum/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : add_prime_sum 2 | Fisere de iesire : add_prime_sum.c 3 | Functii autorizate: write, exit 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti un program care primeste un numar intreg pozitiv ca si parametru si care afiseaza suma tuturor numerelor prime mai mici sau egale decat parametrul primit, urmata de un terminator de linie. 7 | 8 | Dana numarul de argumente nu este 1, sau argumentul nu este un numar pozitiv, afisati doar 0 urmat de terminatorul de linie. 9 | 10 | Exemple: 11 | 12 | $>./add_prime_sum 5 13 | 10 14 | $>./add_prime_sum 7 | cat -e 15 | 17$ 16 | $>./add_prime_sum | cat -e 17 | 0$ 18 | $> 19 | -------------------------------------------------------------------------------- /4-0-ft_list_remove_if/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : ft_list_remove_if 2 | Fisiere de iesire : ft_list_remove_if.c 3 | Functii autorizate : free 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti o functie ft_list_remove_if ce sterge dintr-o lista toate elementele 7 | ale caror data este "egala" cu data de referinta. 8 | 9 | Ea trebuie sa aiba prototipul urmator: 10 | 11 | void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)()); 12 | 13 | La corectare veti dispumne de un fisier ft_list.h astfel incat: 14 | 15 | $>cat ft_list.h 16 | typedef struct s_list 17 | { 18 | struct s_list *next; 19 | void *data; 20 | } t_list; 21 | $> 22 | -------------------------------------------------------------------------------- /2-0-alpha_mirror/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : alpha_mirror 2 | Expected files : alpha_mirror.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme alpha_mirror qui prend une chaîne et l'affiche après en avoir remplacé chaque 7 | caractère alphabétique par le caractère alphabétique opposé, suivie d'un newline. 8 | 9 | 'a' devient 'z', 'Z' devient 'A' 10 | 'd' devient 'w', 'M' devient 'N' 11 | 12 | Etc... 13 | 14 | La casse n'est pas changée. 15 | 16 | Si le nombre d'arguments n'est pas 1, affiche juste un newline. 17 | 18 | Exemples: 19 | 20 | $>./alpha_mirror "abc" 21 | zyx 22 | $>./alpha_mirror "My horse is Amazing." | cat -e 23 | Nb slihv rh Znzarmt.$ 24 | $>./alpha_mirror | cat -e 25 | $ 26 | $> 27 | -------------------------------------------------------------------------------- /3-0-ft_rrange/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_rrange 2 | Expected files : ft_rrange.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following function: 7 | 8 | int *ft_rrange(int start, int end); 9 | 10 | It must allocate (with malloc()) an array of integers, fill it with consecutive 11 | values that begin at end and end at start (Including start and end !), then 12 | return a pointer to the first value of the array. 13 | 14 | Examples: 15 | 16 | - With (1, 3) you will return an array containing 3, 2 and 1 17 | - With (-1, 2) you will return an array containing 2, 1, 0 and -1. 18 | - With (0, 0) you will return an array containing 0. 19 | - With (0, -3) you will return an array containing -3, -2, -1 and 0. 20 | -------------------------------------------------------------------------------- /4-0-ft_list_remove_if/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_list_remove_if 2 | Expected files : ft_list_remove_if.c 3 | Allowed functions: free 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function called ft_list_remove_if that removes from the 7 | passed list any element the data of which is "equal" to the reference data. 8 | 9 | It will be declared as follows : 10 | 11 | void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)()); 12 | 13 | cmp takes two void* and returns 0 when both parameters are equal. 14 | 15 | You have to use the ft_list.h file, which will contain: 16 | 17 | $>cat ft_list.h 18 | typedef struct s_list 19 | { 20 | struct s_list *next; 21 | void *data; 22 | } t_list; 23 | $> 24 | -------------------------------------------------------------------------------- /4-0-ft_list_remove_if/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_list_remove_if 2 | Expected files : ft_list_remove_if.c 3 | Allowed functions: free 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction ft_list_remove_if qui efface de la liste tous les élements 7 | dont la donnée est "égale" à la donnée de référence. 8 | 9 | Elle devra être prototypée de la façon suivante : 10 | 11 | void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)()); 12 | 13 | cmp prends deux void* et renvoie 0 lorsque les 2 paramètres sont égaux. 14 | 15 | À la correction, vous disposez du fichier ft_list.h tel que : 16 | 17 | $>cat ft_list.h 18 | typedef struct s_list 19 | { 20 | struct s_list *next; 21 | void *data; 22 | } t_list; 23 | $> 24 | -------------------------------------------------------------------------------- /3-0-ft_rrange/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_rrange 2 | Expected files : ft_rrange.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire la fonction suivante : 7 | 8 | int *ft_rrange(int start, int end); 9 | 10 | Cette fonction doit allouer avec malloc() un tableau d'ints, le remplir avec 11 | les valeurs (consécutives) démarrant à end et finissant à start (start et end 12 | inclus !), et renvoyer un pointeur vers la première valeur du tableau. 13 | 14 | Exemples: 15 | 16 | - Avec (1, 3) vous devrez renvoyer un tableau contenant 3, 2 et 1. 17 | - Avec (-1, 2) vous devrez renvoyer un tableau contenant 2, 1, 0 et -1. 18 | - Avec (0, 0) vous devrez renvoyer un tableau contenant 0. 19 | - Avec (0, -3) vous devrez renvoyer un tableau contenant -3, -2, -1 et 0. 20 | -------------------------------------------------------------------------------- /3-0-ft_atoi_base/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_atoi_base 2 | Expected files : ft_atoi_base.c 3 | Allowed functions: None 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that converts the string argument str (base N <= 16) 7 | to an integer (base 10) and returns it. 8 | 9 | The characters recognized in the input are: 0123456789abcdef 10 | Those are, of course, to be trimmed according to the requested base. For 11 | example, base 4 recognizes "0123" and base 16 recognizes "0123456789abcdef". 12 | 13 | Uppercase letters must also be recognized: "12fdb3" is the same as "12FDB3". 14 | 15 | Minus signs ('-') are interpreted only if they are the first character of the 16 | string. 17 | 18 | Your function must be declared as follows: 19 | 20 | int ft_atoi_base(const char *str, int str_base); 21 | -------------------------------------------------------------------------------- /3-0-ft_atoi_base/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_atoi_base 2 | Expected files : ft_atoi_base.c 3 | Allowed functions: None 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui convertit son argument 'str', une chaîne (en base N <= 16) 7 | en un entier (base 10) et le retourne. 8 | 9 | Les caractères reconnus dans l'entrée sont : 0123456789abcdef 10 | Bien entendu, la base demandée conditionne le nombre de caractères à prendre 11 | en compte. Par exemple, la base 4 reconnaîtra "0123" et la base 16 reconnaîtra 12 | "0123456789abcdef". 13 | 14 | Les majuscules marchent aussi : "12fdb3" est pareil que "12FDB3". 15 | 16 | Les caractères '-' doivent être interprétés seulement s'ils sont en première 17 | position dans la chaîne. 18 | 19 | Votre fonction sera déclarée comme suit: 20 | 21 | int ft_atoi_base(const char *str, int str_base); 22 | -------------------------------------------------------------------------------- /3-0-ft_rrange/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : ft_rrange 2 | Fisier de iesire : ft_rrange.c 3 | Functii autorizate : malloc 4 | -------------------------------------------------------------------------------- 5 | Scrieti functia urmatoare: 6 | 7 | int *ft_rrange(int start, int end); 8 | 9 | Aceasta functie trebuie sa aloce cu ajutorul functiei malloc() un tablou de 10 | intregi si sa-l umple valori (consecutive) incepand cu endsi terminand cu start 11 | (start si end incluse!), si sa returneze un pointer spre prima valoare a tabloului. 12 | 13 | Exemplu: 14 | 15 | 16 | Cu parametri (1, 3) trebuie sa returnati un tablou continand valorile 3, 2 si 1. 17 | 18 | Cu parametri (-1, 2) trebuie sa returnati un tablou continand valorile 2, 1, 0 si -1. 19 | 20 | Cu parametri (0, 0) trebuie sa returnati un tablou continand valorile 0. 21 | 22 | Cu parametri (0, -3) trebuie sa returnati un tablou continand valorile -3, -2, -1 si 0. 23 | -------------------------------------------------------------------------------- /5-0-print_memory/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Assignment name : print_memory 2 | Expected files : print_memory.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti o functie care primeste (const void *addr, size_t size), si afiseaza memoria precum in exemplu. 7 | 8 | Functia trebuie declarata ca si mai jos: 9 | 10 | void print_memory(const void *addr, size_t size); 11 | 12 | --------- 13 | $> cat main.c 14 | void print_memory(const void *addr, size_t size); 15 | 16 | int main(void) 17 | { 18 | int tab[10] = {0, 23, 150, 255, 19 | 12, 16, 21, 42}; 20 | 21 | print_memory(tab, sizeof(tab)); 22 | return (0); 23 | } 24 | $> gcc -Wall -Wall -Werror main.c print_memory.c && ./a.out | cat -e 25 | 0000 0000 1700 0000 9600 0000 ff00 0000 ................$ 26 | 0c00 0000 1000 0000 1500 0000 2a00 0000 ............*...$ 27 | 0000 0000 0000 0000 ........$ 28 | 29 | -------------------------------------------------------------------------------- /5-0-print_memory/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : print_memory 2 | Expected files : print_memory.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes (const void *addr, size_t size), and displays the 7 | memory as in the example. 8 | 9 | Your function must be declared as follows: 10 | 11 | void print_memory(const void *addr, size_t size); 12 | 13 | --------- 14 | $> cat main.c 15 | void print_memory(const void *addr, size_t size); 16 | 17 | int main(void) 18 | { 19 | int tab[10] = {0, 23, 150, 255, 20 | 12, 16, 42, 103}; 21 | 22 | print_memory(tab, sizeof(tab)); 23 | return (0); 24 | } 25 | $> gcc -Wall -Wall -Werror main.c print_memory.c && ./a.out | cat -e 26 | 0000 0000 1700 0000 9600 0000 ff00 0000 ................$ 27 | 0c00 0000 1000 0000 2a00 0000 6700 0000 ........*...g...$ 28 | 0000 0000 0000 0000 ........$ 29 | 30 | -------------------------------------------------------------------------------- /4-1-fprime/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : fprime 2 | Expected files : fprime.c 3 | Allowed functions: printf, atoi 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a positive int and displays its prime factors on the 7 | standard output, followed by a newline. 8 | 9 | Factors must be displayed in ascending order and separated by '*', so that 10 | the expression in the output gives the right result. 11 | 12 | If the number of parameters is not 1, simply display a newline. 13 | 14 | The input, when there's one, will be valid. 15 | 16 | Examples: 17 | 18 | $> ./fprime 225225 | cat -e 19 | 3*3*5*5*7*11*13$ 20 | $> ./fprime 8333325 | cat -e 21 | 3*3*5*5*7*11*13*37$ 22 | $> ./fprime 9539 | cat -e 23 | 9539$ 24 | $> ./fprime 804577 | cat -e 25 | 804577$ 26 | $> ./fprime 42 | cat -e 27 | 2*3*7$ 28 | $> ./fprime 1 | cat -e 29 | 1$ 30 | $> ./fprime | cat -e 31 | $ 32 | $> ./fprime 42 21 | cat -e 33 | $ 34 | -------------------------------------------------------------------------------- /5-0-print_memory/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : print_memory 2 | Expected files : print_memory.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire une fonction qui prend (const void *addr, size_t size) et affiche la mémoire pointée comme dans l'exemple. 7 | 8 | Votre fonction sera prototypée comme suit: 9 | 10 | void print_memory(const void *addr, size_t size); 11 | 12 | --------- 13 | $> cat main.c 14 | void print_memory(const void *addr, size_t size); 15 | 16 | int main(void) 17 | { 18 | int tab[10] = {0, 23, 150, 255, 19 | 12, 16, 42, 103}; 20 | 21 | print_memory(tab, sizeof(tab)); 22 | return (0); 23 | } 24 | $> gcc -Wextra -Wall -Werror main.c print_memory.c && ./a.out | cat -e 25 | 0000 0000 1700 0000 9600 0000 ff00 0000 ................$ 26 | 0c00 0000 1000 0000 2a00 0000 6700 0000 ........*...g...$ 27 | 0000 0000 0000 0000 ........$ 28 | 29 | -------------------------------------------------------------------------------- /2-0-union/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : union 2 | Expected files : union.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire un programme nommé union qui prend en paramètre deux chaînes de 7 | caractères et qui affiche, sans doublon, les caractères qui apparaissent dans 8 | l'une ou dans l'autre. 9 | 10 | L'affichage se fera dans l'ordre d'apparition dans la ligne de commande. 11 | 12 | L'affichage doit etre suivi d'un retour à la ligne. 13 | 14 | Si le nombre de paramètres transmis est différent de 2, le programme affiche 15 | \n. 16 | 17 | Exemple: 18 | 19 | $>./union zpadinton "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 20 | zpadintoqefwjy$ 21 | $>./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 22 | df6vewg4thras$ 23 | $>./union "rien" "cette phrase ne cache rien" | cat -e 24 | rienct phas$ 25 | $>./union | cat -e 26 | $ 27 | $> 28 | $>./union "rien" | cat -e 29 | $ 30 | $> 31 | -------------------------------------------------------------------------------- /biggest_pal/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : biggest_pal 2 | Expected files : *.c, *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program named biggest_pal that takes a string as argument and prints the 7 | biggest palindrome included inside this string, followed by a newline. 8 | 9 | This string contains only lowercase characters. 10 | 11 | If there is two palindromes of the same length, you have to print the last one. 12 | 13 | If there is more or less than 1 argument, your program must print only a newline 14 | only. 15 | 16 | Exemples: 17 | 18 | $> biggest_pal "abcba" 19 | abcba 20 | $> biggest_pal "aaaaaaaaaabbcbbaaaa" 21 | aaaabbcbbaaaa 22 | $> biggest_pal "aooibdaoiwhoihwdoinzeldaisaboyobasiadlezfdsfnslk" 23 | zeldaisaboyobasiadlez 24 | $> biggest_pal "aeibaabaammaabaalek" 25 | aabaammaabaa 26 | $> biggest_pal abeb qpinqwjobo qkmnwoiq 27 | 28 | $> biggest_pal 29 | 30 | $> 31 | 32 | -------------------------------------------------------------------------------- /3-0-lcm/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : lcm 2 | Expected files : lcm.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire une fonction qui calcule le LCM (Lowest Common Multiple ou Plus Petit 7 | Commun Multiple). Le LCM de deux nombres entiers naturels (non nuls) est leur 8 | plus petit multiple commun non nul. 9 | 10 | Vous pouvez calculer le LCM de deux manieres: 11 | 12 | - Vous pouvez prendre tous les multiples de chaques entiers et definir le 13 | premier multiple non nul commun aux deux entiers comme etant le LCM 14 | 15 | - Vous pouvez utiliser le HCF ou Highest Common Factor (ou PGCD) de ces deux 16 | entiers et calculer le LCM comme suit : 17 | 18 | LCM(x, y) = | x * y | / HCF(x, y) 19 | 20 | | x * y | etant la valeur absolue du produit de x par y 21 | 22 | 23 | Si l'un des deux entiers est nul, alors le LCM est egal a 0. 24 | 25 | Votre fonction sera prototype comme suit : 26 | 27 | unsigned int lcm(unsigned int a, unsigned int b); 28 | -------------------------------------------------------------------------------- /5-0-cycle_detector/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : cycle_detector 2 | Expected files : cycle_detector.c 3 | Allowed functions: malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Créez une fonction cycle_detector qui prends un "const t_list *list" en 7 | argument, qui vérifiera qu'il n'y a aucun cycle à l'intérieur de la liste chainée 8 | list. 9 | 10 | Un cycle est défini quand, lors du parcours de la liste, vous passez au moins 2 11 | fois à travers le même maillon. 12 | 13 | Cette fonction retournera 1 si la fonction détecte un cycle, sinon elle renverra 0. 14 | 15 | Cette fonction sera prototypé comme suit : 16 | 17 | int cycle_detector(const t_list *list) 18 | 19 | Le type "t_list" est défini comme suit : 20 | 21 | typedef struct s_list 22 | { 23 | int data; 24 | struct s_list *next; 25 | } t_list; 26 | 27 | Ce type sera fourni dans le header "list.h". Vous n'avez pas besoin de le fournir, 28 | nous utiliserons le notre en correction. -------------------------------------------------------------------------------- /biggest_pal/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : biggest_pal 2 | Expected files : *.c, *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme nommé biggest_pal, qui prend en paramètre une chaîne de 7 | caractères, et qui affiche le plus grand palindrome trouvé dans cette chaîne suivi 8 | d'une newline. 9 | 10 | La chaine passée en paramètre ne contient uniquement que des lettres minuscules. 11 | 12 | Si il y a 2 palindromes de meme taille, celui à imprimer sera le dernier rencontré. 13 | 14 | Si le programme reçoit un nombre d'arguments différent de 1, vous ne renverrez 15 | qu'une newline. 16 | 17 | Exemples: 18 | 19 | $> biggest_pal "abcba" 20 | abcba 21 | $> biggest_pal "aaaaaaaaaabbcbbaaaa" 22 | aaaabbcbbaaaa 23 | $> biggest_pal "aooibdaoiwhoihwdoinzeldaisaboyobasiadlezfdsfnslk" 24 | zeldaisaboyobasiadlez 25 | $> biggest_pal "aeibaabaammaabaalek" 26 | aabaammaabaa 27 | $> biggest_pal abeb qpinqwjobo qkmnwoiq 28 | 29 | $> biggest_pal 30 | 31 | $> 32 | -------------------------------------------------------------------------------- /0-0-only_a/only_a.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* only_a.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/01 18:13:46 by exam #+# #+# */ 9 | /* Updated: 2018/01/11 14:34:56 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(void) 16 | { 17 | write(1, "a", 1); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0-1-only_z/only_z.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* only_z.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/13 11:37:09 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/13 11:39:02 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(void) 16 | { 17 | write(1, "z", 1); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /2-1-swap_bits/swap_bits.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* swap_bits.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/13 16:17:50 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/13 16:19:26 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | unsigned char swap_bits(unsigned char octet) 14 | { 15 | return ((octet >> 4) + (octet << 4)); 16 | } 17 | -------------------------------------------------------------------------------- /4-0-sort_list/list.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* list.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: zaz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2014/02/27 13:14:10 by zaz #+# #+# */ 9 | /* Updated: 2014/02/27 13:15:29 by zaz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | typedef struct s_list t_list; 14 | 15 | struct s_list 16 | { 17 | int data; 18 | t_list *next; 19 | }; 20 | -------------------------------------------------------------------------------- /4-0-rev_wstr/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : rev_wstr 2 | Fisiere de iesire : rev_wstr.c 3 | Functii autorizate : write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti un program ce ia ca parametru un sir de caractere si care afiseaza acest 7 | sir inversand cuvintele sale. 8 | 9 | Numim "cuvant" o portiune a sirului de caractere delimitat, fie de spatiu si/sau 10 | tabulator, fie de inceputul/sfarsitul sirului. 11 | 12 | Daca numarul de parametri este diferit de 1, programul va afisa '\n'. 13 | 14 | Sirurile ce urmeaza a fi testate nu vor contine spatii nici la inceput si nici 15 | la sfarsitul acestora si ca cuvintele vor fi separate intotdeauna printr-un spatiu. 16 | 17 | Exemplu: 18 | 19 | $> ./rev_wstr "le temps du mepris precede celui de l'indifference" | cat -e 20 | l'indifference de celui precede mepris du temps le$ 21 | $> ./rev_wstr "abcdefghijklm" 22 | abcdefghijklm 23 | $> ./rev_wstr "il contempla le mont" | cat -e 24 | mont le contempla il$ 25 | $> ./rev_wstr | cat -e 26 | $ 27 | $> 28 | -------------------------------------------------------------------------------- /5-0-cycle_detector/list.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* list.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: zaz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2014/02/27 13:14:10 by zaz #+# #+# */ 9 | /* Updated: 2014/02/27 13:15:29 by zaz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | typedef struct s_list t_list; 14 | 15 | struct s_list 16 | { 17 | int data; 18 | t_list *next; 19 | }; 20 | -------------------------------------------------------------------------------- /4-0-moment/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : moment 2 | Expected files : moment.c 3 | Allowed functions: malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Create a function that takes a duration in seconds as parameter and returns a 7 | string with the number of seconds, minutes, hours, days or months elapsed. 8 | This function supposes that months are 30-days long and ignores leap years. 9 | 10 | The format of this string will be : 11 | 12 | xxx {second(s)|minute(s)|hour(s)|day(s)|month(s)} ago. 13 | 14 | Your function should return the lowest possible value (as you can see below 15 | in the examples). 16 | 17 | The prototype of this function will be : 18 | 19 | char *moment(unsigned int duration) 20 | 21 | Examples: 22 | 23 | moment(0) => 0 seconds ago. 24 | moment(1) => 1 second ago. 25 | moment(30) => 30 seconds ago. 26 | moment(65) => 1 minute ago. 27 | moment(120) => 2 minutes ago. 28 | moment(2400) => 40 minutes ago. 29 | moment(3735) => 1 hour ago. 30 | -------------------------------------------------------------------------------- /4-1-fprime/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : fprime 2 | Fisiere de iesire : fprime.c 3 | Functii autorizate : printf, atoi 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti un program ce ia ca parametru un intreg strict pozitiv si care va afisa 7 | descompunerea in factori primi la iesirea standard, urmat de un '\n'. 8 | 9 | Factorii trebuie sa fie afisati in ordine crescatoare si separati de '*', 10 | astfel incat expresia afisata sa dea rezultatul corect. 11 | 12 | Daca numarul de parametri este diferit de 1, programul va afisa '\n'. 13 | 14 | Parametrul de intrare, cand este transmis, va fi totdeauna un numar valid 15 | fara caractere neconforme. 16 | 17 | Exemplu: 18 | 19 | $> ./fprime 225225 | cat -e 20 | 3*3*5*5*7*11*13$ 21 | $> ./fprime 8333325 | cat -e 22 | 3*3*5*5*7*11*13*37$ 23 | $> ./fprime 9539 | cat -e 24 | 9539$ 25 | $> ./fprime 804577 | cat -e 26 | 804577$ 27 | $> ./fprime 42 | cat -e 28 | 2*3*7$ 29 | $> ./fprime 1 | cat -e 30 | 1$ 31 | $> ./fprime | cat -e 32 | $ 33 | $> ./fprime 42 21 | cat -e 34 | $ 35 | -------------------------------------------------------------------------------- /5-0-cycle_detector/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : cycle_detector 2 | Expected files : cycle_detector.c 3 | Allowed functions: malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Create a function named cycle_detector that takes a const t_list *list 7 | as argument, and check if the given linked list contains no cycles. 8 | 9 | A cycle is defined when you go at least twice through the same link, when you 10 | travel inside a linked list. 11 | 12 | This function should returnw 1 if it detects a cycle inside the given linked 13 | list, otherwise it returns 0. 14 | 15 | This function should be prototyped like this: 16 | 17 | int cycle_detector(const t_list *list) 18 | 19 | The type t_list is: 20 | 21 | typedef struct s_list 22 | { 23 | int data; 24 | struct s_list *next; 25 | } t_list; 26 | 27 | This type will be included in a header named "list.h". You don't have to turn-in 28 | your "list.h", we will use ours during the evaluation. 29 | -------------------------------------------------------------------------------- /0-0-ft_print_numbers/ft_print_numbers_easy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_numbers_easy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/13 12:01:05 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/13 12:08:47 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_numbers(void) 16 | { 17 | write(1, "0123456789", 10); 18 | } 19 | -------------------------------------------------------------------------------- /0-1-ft_countdown/ft_countdown_easy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_countdown_easy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/13 12:18:15 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/13 12:20:09 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(void) 16 | { 17 | write(1, "9876543210\n", 11); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0-2-maff_revalpha/maff_revalpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maff_revalpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 10:11:52 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 10:38:55 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(void) 16 | { 17 | write(1, "zYxWvUtSrQpOnMlKjIhGfEdCbA\n", 27); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /3-0-rstr_capitalizer/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rstr_capitalizer 2 | Expected files : rstr_capitalizer.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes one or more strings and, for each argument, puts 7 | the last character of each word (if it's a letter) in uppercase and the rest 8 | in lowercase, then displays the result followed by a \n. 9 | 10 | A word is a section of string delimited by spaces/tabs or the start/end of the 11 | string. If a word has a single letter, it must be capitalized. 12 | 13 | If there are no parameters, display \n. 14 | 15 | Examples: 16 | 17 | $> ./rstr_capitalizer | cat -e 18 | $ 19 | $> ./rstr_capitalizer "Premier PETIT TesT" | cat -e 20 | premieR petiT tesT$ 21 | $> ./rstr_capitalizer "DeuxiEmE tEST uN PEU moinS facile" " attention C'EST pas dur QUAND mEmE" "ALLer UN DeRNier 0123456789pour LA rouTE E " | cat -e 22 | deuxiemE tesT uN peU moinS facilE$ 23 | attentioN c'esT paS duR quanD memE$ 24 | alleR uN dernieR 0123456789pouR lA routE E $ 25 | $> 26 | -------------------------------------------------------------------------------- /4-0-moment/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : moment 2 | Expected files : moment.c 3 | Allowed functions: malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Créer une fonction qui prends un unsigned int en paramètre, représentant une 7 | potentielle durée en secondes, et renvoie une chaîne de caractères qui indique le 8 | nombre de secondes / minutes / heures / jours ou mois écoulés. 9 | On supposera que les mois font 30 jours de long et on ignore les années bissextiles. 10 | 11 | Le format de sortie sera : 12 | 13 | xxx {second(s)|minute(s)|hour(s)|day(s)|month(s)} ago. 14 | 15 | Votre fonction ne renverra que la durée avec la valeur la plus basse possible. 16 | La fonction sera prototypée comme suit: 17 | 18 | char *moment(unsigned int duration) 19 | 20 | Exemples: 21 | 22 | moment(0) => 0 seconds ago. 23 | moment(1) => 1 second ago. 24 | moment(30) => 30 seconds ago. 25 | moment(65) => 1 minute ago. 26 | moment(120) => 2 minutes ago. 27 | moment(2400) => 40 minutes ago. 28 | moment(3735) => 1 hour ago. 29 | -------------------------------------------------------------------------------- /4-1-fprime/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : fprime 2 | Expected files : fprime.c 3 | Allowed functions: printf, atoi 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètre un entier strictement positif, et 7 | qui affiche sa décomposition en facteurs premiers sur la sortie standard, 8 | suivie d'un '\n'. 9 | 10 | Les facteurs doivent être affichés dans l'ordre croissant et séparés par des 11 | '*', de telle sorte que l'expression affichée donne le bon résultat. 12 | 13 | Si le nombre de paramètres est différent de 1, le programme doit afficher '\n'. 14 | 15 | L'entrée, quand elle est passée, sera toujours un nombre valide sans caractères 16 | parasites. 17 | 18 | Exemple: 19 | 20 | $> ./fprime 225225 | cat -e 21 | 3*3*5*5*7*11*13$ 22 | $> ./fprime 8333325 | cat -e 23 | 3*3*5*5*7*11*13*37$ 24 | $> ./fprime 9539 | cat -e 25 | 9539$ 26 | $> ./fprime 804577 | cat -e 27 | 804577$ 28 | $> ./fprime 42 | cat -e 29 | 2*3*7$ 30 | $> ./fprime 1 | cat -e 31 | 1$ 32 | $> ./fprime | cat -e 33 | $ 34 | $> ./fprime 42 21 | cat -e 35 | $ 36 | -------------------------------------------------------------------------------- /4-0-rev_wstr/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_wstr 2 | Expected files : rev_wstr.c 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string as a parameter, and prints its words in 7 | reverse order. 8 | 9 | A "word" is a part of the string bounded by spaces and/or tabs, or the 10 | begin/end of the string. 11 | 12 | If the number of parameters is different from 1, the program will display 13 | '\n'. 14 | 15 | In the parameters that are going to be tested, there won't be any "additional" 16 | spaces (meaning that there won't be additionnal spaces at the beginning or at 17 | the end of the string, and words will always be separated by exactly one space). 18 | 19 | Examples: 20 | 21 | $> ./rev_wstr "le temps du mepris precede celui de l'indifference" | cat -e 22 | l'indifference de celui precede mepris du temps le$ 23 | $> ./rev_wstr "abcdefghijklm" 24 | abcdefghijklm 25 | $> ./rev_wstr "il contempla le mont" | cat -e 26 | mont le contempla il$ 27 | $> ./rev_wstr | cat -e 28 | $ 29 | $> 30 | -------------------------------------------------------------------------------- /4-2-cycle_detector/list.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* list.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/02/12 16:10:43 by lsauvage #+# #+# */ 9 | /* Updated: 2018/02/12 16:24:01 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef LIST_H 14 | # define LIST_H 15 | 16 | typedef struct s_list 17 | { 18 | struct s_list *next; 19 | void *data; 20 | } t_list; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /4-0-sort_list/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : sort_list 2 | Expected files : sort_list.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following functions: 7 | 8 | t_list *sort_list(t_list* lst, int (*cmp)(int, int)); 9 | 10 | This function must sort the list given as a parameter, using the function 11 | pointer cmp to select the order to apply, and returns a pointer to the 12 | first element of the sorted list. 13 | 14 | Duplications must remain. 15 | 16 | Inputs will always be consistent. 17 | 18 | You must use the type t_list described in the file list.h 19 | that is provided to you. You must include that file 20 | (#include "list.h"), but you must not turn it in. We will use our own 21 | to compile your assignment. 22 | 23 | Functions passed as cmp will always return a value different from 24 | 0 if a and b are in the right order, 0 otherwise. 25 | 26 | For example, the following function used as cmp will sort the list 27 | in ascending order: 28 | 29 | int ascending(int a, int b) 30 | { 31 | return (a <= b); 32 | } 33 | -------------------------------------------------------------------------------- /0-2-strlen_sh/strlen2.sh: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # strlen2.sh :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: lsauvage +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2018/01/12 11:33:32 by lsauvage #+# #+# # 9 | # Updated: 2018/01/12 12:27:24 by lsauvage ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/bin/sh 14 | # resultat OK avec 'source strlen2.sh' 15 | string=(echo $FT_LINE) 16 | 17 | if [ "$string" ]; then 18 | echo -n $FT_LINE | wc -m | sed 's/^[ \t]*//' 19 | fi 20 | -------------------------------------------------------------------------------- /4-2-ft_list_foreach/ft_list.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_list.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/02/12 16:10:43 by lsauvage #+# #+# */ 9 | /* Updated: 2018/02/12 16:24:01 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_LIST_H 14 | # define FT_LIST_H 15 | 16 | typedef struct s_list 17 | { 18 | struct s_list *next; 19 | void *data; 20 | } t_list; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /2-1-ft_swap/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/01 21:39:56 by exam #+# #+# */ 9 | /* Updated: 2017/09/01 21:45:20 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_swap(int *a, int *b) 16 | { 17 | int *a; 18 | int *b; 19 | int *swap; 20 | 21 | int *swap = int *b; 22 | int *b = int *a; 23 | int *a = int *swap; 24 | } 25 | -------------------------------------------------------------------------------- /5-0-brackets/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : brackets 2 | Expected files : *.c *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes an undefined number of strings in arguments. For each 7 | argument, the program prints on the standard output "OK" followed by a newline 8 | if the expression is correctly bracketed, otherwise it prints "Error" followed by 9 | a newline. 10 | 11 | Symbols considered as 'brackets' are brackets '(' and ')', square brackets '[' 12 | and ']'and braces '{' and '}'. Every other symbols are simply ignored. 13 | 14 | An opening bracket must always be closed by the good closing bracket in the 15 | correct order. A string which not contains any bracket is considered as a 16 | correctly bracketed string. 17 | 18 | If there is no arguments, the program must print only a newline. 19 | 20 | Examples : 21 | 22 | $> ./brackets '(johndoe)' | cat -e 23 | OK$ 24 | $> ./brackets '([)]' | cat -e 25 | Error$ 26 | $> ./brackets '' '{[(0 + 0)(1 + 1)](3*(-1)){()}}' | cat -e 27 | OK$ 28 | OK$ 29 | $> ./brackets | cat -e 30 | $ 31 | $> 32 | -------------------------------------------------------------------------------- /0-2-aff_last_param/aff_last_param.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* aff_last_param.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/11 15:00:31 by lsauvage #+# #+# */ 9 | /* Updated: 2018/01/11 15:15:15 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | if (ac > 1) 18 | while (*av[ac - 1]) 19 | write(1, av[ac - 1]++, 1); 20 | write(1, "\n", 1); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /2-1-do_op/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : do_op 2 | Expected files : *.c, *.h 3 | Allowed functions: atoi, printf, write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètre trois chaìnes de caractères: 7 | - La première et la troisième sont des représentations en base 10 de 8 | nombre entiers signés, tenant dans des int. 9 | - La deuxième est un opérateur arithmétique parmi $+ - * / \%$. 10 | 11 | Le programme doit afficher le resultat de l'opération arithmétique demandée, 12 | suivi d'un '\n'. Si le nombre de paramètres est différent de 3, le programme 13 | doit afficher '\n'. 14 | 15 | Vous pouvez partir du principe que les chaînes ne comportent ni erreur, ni 16 | caractères indésirables. Les nombres négatifs, en entrée comme en sortie, 17 | seront précédés d'un et un seul signe '-'. Le résultat de l'opération tient 18 | dans un int. 19 | 20 | Exemples: 21 | 22 | $> ./do_op "123" "*" 456 | cat -e 23 | 56088$ 24 | $> ./do_op "9828" "/" 234 | cat -e 25 | 42$ 26 | $> ./do_op "1" "+" "-43" | cat -e 27 | -42$ 28 | $> ./do_op | cat -e 29 | $ 30 | -------------------------------------------------------------------------------- /4-0-rev_wstr/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_wstr 2 | Expected files : rev_wstr.c 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètre une chaîne de caractères, et qui 7 | affiche cette chaîne en inversant ses mots. 8 | 9 | On appelle "mot" une portion de chaîne de caractères délimitée soit par des 10 | espaces et/ou des tabulations, soit par le début / fin de la chaîne. 11 | 12 | Si le nombre de paramètres est différent de 1, le programme devra afficher 13 | '\n'. 14 | 15 | Dans les paramètres qui seront testés, il n'y aura pas d'espaces "en trop" 16 | (comprendre par là qu'il n'y aura pas d'espaces au début ou à la fin de la 17 | chaîne, et que les mots seront toujours séparés par exactement un espace). 18 | 19 | Exemple: 20 | 21 | $> ./rev_wstr "le temps du mepris precede celui de l'indifference" | cat -e 22 | l'indifference de celui precede mepris du temps le$ 23 | $> ./rev_wstr "abcdefghijklm" 24 | abcdefghijklm 25 | $> ./rev_wstr "il contempla le mont" | cat -e 26 | mont le contempla il$ 27 | $> ./rev_wstr | cat -e 28 | $ 29 | $> 30 | -------------------------------------------------------------------------------- /2-2-max/max.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* max.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 15:11:12 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 15:31:09 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int max(int *tab, unsigned int len) 14 | { 15 | unsigned int i; 16 | int max; 17 | 18 | i = 0; 19 | max = 0; 20 | while (i < len) 21 | { 22 | if (tab[i] > max) 23 | max = tab[i]; 24 | i++; 25 | } 26 | return (max); 27 | } 28 | -------------------------------------------------------------------------------- /0-2-strlen_sh/strlen.sh: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # strlen.sh :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: lsauvage +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2018/01/11 15:17:52 by lsauvage #+# #+# # 9 | # Updated: 2018/01/12 12:27:27 by lsauvage ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/bin/sh 14 | # affichage de la variable FT_LINE | compte les caracteres | supprime les 15 | # espaces en debut de ligne 16 | # resultat OK en utilisant la commande 'source strlen.sh' 17 | echo -n $FT_LINE | wc -m | sed 's/^[ \t]*//' 18 | -------------------------------------------------------------------------------- /4-2-ft_list_foreach/ft_list_foreach.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_list_foreach.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/02/12 16:10:20 by lsauvage #+# #+# */ 9 | /* Updated: 2018/02/12 16:23:53 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft_list.h" 14 | 15 | void ft_list_foreach(t_list *begin_list, void (*f)(void *)) 16 | { 17 | t_list *list; 18 | 19 | list = begin_list; 20 | while (list) 21 | { 22 | (*f)(list->data); 23 | list = list->next; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /0-0-ft_print_numbers/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_numbers.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/01 19:48:03 by exam #+# #+# */ 9 | /* Updated: 2017/12/13 12:09:04 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_print_numbers(void) 21 | { 22 | int i; 23 | 24 | i = 48; 25 | while (i <= 57) 26 | { 27 | ft_putchar(i); 28 | i++; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /0-1-ft_countdown/ft_countdown.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_countdown.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/06 14:10:06 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/06 19:21:08 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | int main(void) 21 | { 22 | char c; 23 | 24 | c = '9'; 25 | while (c >= '0') 26 | { 27 | ft_putchar(c); 28 | c--; 29 | } 30 | ft_putchar('\n'); 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /4-0-sort_list/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : sort_list 2 | Expected files : sort_list.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire la fonction suivante: 7 | 8 | t_list *sort_list(t_list* lst, int (*cmp)(int, int)); 9 | 10 | Cette fonction doit trier la liste passée en premier paramètre, en utilisant le 11 | pointeur sur fonction cmp pour déterminer l'ordre à appliquer, et 12 | renvoyer un pointeur vers le premier élément de la liste triée. 13 | 14 | Les doublons doivent être préservés. 15 | 16 | Les entrées seront toujours cohérentes. 17 | 18 | Vous devez utiliser le type t_list décrit dans le fichier list.h qui vous est 19 | fourni. Vous devrez inclure (#include "list.h") ce fichier, mais ne pas le 20 | rendre. Nous utiliserons le notre pour compiler votre exercice. 21 | 22 | Les fonctions passées en tant que cmp renverront toujours une valeur 23 | différente de 0 si a et b sont dans le bon ordre, 24 | dans le cas contraire elles renverront 0. 25 | 26 | Par exemple, la fonction suivante utilisée en tant que cmp devra 27 | permettre de trier la liste par ordre croissant: 28 | 29 | int croissant(int a, int b) 30 | { 31 | return (a <= b); 32 | } 33 | -------------------------------------------------------------------------------- /4-0-sort_list/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : sort_list 2 | Fisiere de iesire : sort_list.c 3 | Functii autorizate : 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti functia urmatoare: 7 | 8 | t_list *sort_list(t_list* lst, int (*cmp)(int, int)); 9 | 10 | Aceasta functie trebuie sa sorteze lista transmisa ca prim parametru, utilizand 11 | un pointer spre functia cmp pentru a determina ordinea de aplicare, si 12 | returneaza un pointer spre primul element al listei sortate. 13 | 14 | Dublurile trebuie pastrate. 15 | 16 | Valorile de intrare vor fi totdeauna coerente. 17 | 18 | Trebuie sa utilizati tipul t_list descris in fisierul list.h care va va fi furnizat. 19 | Trebuie sa includeti (#include "list.h") acest fisier, dar nu trebuie sa predati 20 | acest fisier. Vom olosi fisierul nostru pentru compilarea exercitiului. 21 | 22 | Functiile transmise ca cmp vor returna intodeauna o valoare diferita de 0 daca a si 23 | b sunt in ordinea corespunzatoare, in caz contrar ele vor returna 0. 24 | 25 | De exemplu, functia urmatoare utilizata ca cmp trebuie sa permita trierea listei 26 | in ordine crescatoare: 27 | 28 | int ascending(int a, int b) 29 | { 30 | return (a <= b); 31 | } 32 | -------------------------------------------------------------------------------- /5-0-brackets/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : brackets 2 | Expected files : *.c *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire un programme qui prendra une chaine de caractères en paramètre et qui 7 | écrit sur la sortie standard 'OK' si l'expression est bien parenthesée et 8 | 'Error' dans le cas contraire, le tout suivi d'une newline. 9 | 10 | Les symboles utilisés comme 'parenthèses' seront les parenthèses '(' et ')', les 11 | crochets '[' et ']' ainsi que les accolades '{' et '}'. Tous les autres 12 | caractères seront tout simplement ignorés. 13 | 14 | Une parenthèse ouvrante devra obligatoirement être fermée par une parenthèse 15 | fermante et dans le bon ordre (parenthèses imbriquées). Une chaine ne comportant 16 | aucune parenthèse est considerée comme bien parenthesée. 17 | 18 | Votre programme évaluera tous les arguments. Si aucun argument n'est fourni, 19 | il affichera seulement une newline. 20 | 21 | Exemples : 22 | 23 | $> ./brackets '(jo:qahndoe)' | cat -e 24 | OK$ 25 | $> ./brackets '([)]' | cat -e 26 | Error$ 27 | $> ./brackets '' '{[(0 + 0)(1 + 1)](3*(-1)){()}}' | cat -e 28 | OK$ 29 | OK$ 30 | $> ./brackets | cat -e 31 | $ 32 | $> 33 | -------------------------------------------------------------------------------- /2-2-ft_strrev/ft_strrev.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strrev.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 14:17:37 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 14:57:16 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strrev(char *str) 14 | { 15 | int i; 16 | int j; 17 | char temp; 18 | 19 | i = 0; 20 | j = 0; 21 | while (str[i]) 22 | i++; 23 | i--; 24 | while (i >= 0 && j < i) 25 | { 26 | temp = str[j]; 27 | str[j] = str[i]; 28 | str[i] = temp; 29 | i--; 30 | j++; 31 | } 32 | return (str); 33 | } 34 | -------------------------------------------------------------------------------- /3-0-rstr_capitalizer/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : rstr_capitalizer 2 | Fisiere de iesire : rstr_capitalizer.c 3 | Functii autorizate : write 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti un program ce ia caparametru unul sau mai multe siruri de caractere si care, 7 | pentru fiecare argument, transforma ultimul caracter al fiecarui cuvant (daca e 8 | vorba de olitera, evident) in majuscula, iar restul in minuscule, afisand rezultatul 9 | la iesirea standard urmat de '\n'. 10 | 11 | Numim "cuvant" o portiune din sirul de caractere delimitata, fie cu spatii si/sau 12 | tabulatoare, fie de inceputul/sfarsitul sirului. Daca un cuvant are o singura litera, 13 | ea va fi transormata in majuscula. 14 | 15 | Daca nu e transmis niciun parametru programul va afisa '\n'. 16 | 17 | Exemplu: 18 | 19 | $> ./rstr_capitalizer | cat -e 20 | $ 21 | $> ./rstr_capitalizer "Premier PETIT TesT" | cat -e 22 | premieR petiT tesT$ 23 | $> ./rstr_capitalizer "DeuxiEmE tEST uN PEU moinS facile" " attention C'EST pas dur QUAND mEmE" "ALLer UN DeRNier 0123456789pour LA rouTE E " | cat -e 24 | deuxiemE tesT uN peU moinS facilE$ 25 | attentioN c'esT paS duR quanD memE$ 26 | alleR uN dernieR 0123456789pouR lA routE E $ 27 | $> 28 | -------------------------------------------------------------------------------- /0-0-aff_a/aff_a.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* aff_a.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/11 14:38:03 by lsauvage #+# #+# */ 9 | /* Updated: 2018/01/11 14:53:49 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | if (ac != 2) 18 | write(1, "a", 1); 19 | else 20 | { 21 | while (*av[1]) 22 | { 23 | if (*av[1] == 'a') 24 | { 25 | write(1, "a", 1); 26 | break ; 27 | } 28 | av[1]++; 29 | } 30 | } 31 | write(1, "\n", 1); 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /2-3-ft_strdup/ft_strdup.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strdup.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 15:37:32 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 15:50:37 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strdup(char *src) 16 | { 17 | char *dest; 18 | int i; 19 | 20 | i = 0; 21 | while (src[i]) 22 | i++; 23 | dest = (char*)malloc(sizeof(*dest) * i + 1); 24 | i = 0; 25 | while (src[i]) 26 | { 27 | dest[i] = src[i]; 28 | i++; 29 | } 30 | dest[i] = '\0'; 31 | return (dest); 32 | } 33 | -------------------------------------------------------------------------------- /3-0-rstr_capitalizer/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rstr_capitalizer 2 | Expected files : rstr_capitalizer.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètre une ou plusieurs chaînes de 7 | caractères, et qui, pour chaque argument, met le dernier caractère de chaque 8 | mot (s'il s'agit d'une lettre, évidemment) en majuscule et le reste en 9 | minuscule, et affiche le résultat sur la sortie standard suivi d'un 10 | '\n'. 11 | 12 | On appelle "mot" une portion de chaîne de caractères délimitée soit par des 13 | espaces et/ou des tabulations, soit par le début / fin de la chaîne. Si un mot 14 | a une seule lettre, elle devra être mise en majuscule. 15 | 16 | S'il n'y a aucun paramêtre, le programme devra afficher '\n'. 17 | 18 | Exemple: 19 | 20 | $> ./rstr_capitalizer | cat -e 21 | $ 22 | $> ./rstr_capitalizer "Premier PETIT TesT" | cat -e 23 | premieR petiT tesT$ 24 | $> ./rstr_capitalizer "DeuxiEmE tEST uN PEU moinS facile" " attention C'EST pas dur QUAND mEmE" "ALLer UN DeRNier 0123456789pour LA rouTE E " | cat -e 25 | deuxiemE tesT uN peU moinS facilE$ 26 | attentioN c'esT paS duR quanD memE$ 27 | alleR uN dernieR 0123456789pouR lA routE E $ 28 | $> 29 | -------------------------------------------------------------------------------- /options/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : options 2 | Expected files : *.c *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes an undefined number of arguments which could be 7 | considered as options and writes on standard output a representation of those 8 | options as groups of bytes followed by a newline. 9 | 10 | An option is an argument that begins by a '-' and have multiple characters 11 | which could be : abcdefghijklmnopqrstuvwxyz 12 | 13 | All options are stocked in a single int and each options represents a bit of that 14 | int, and should be stocked like this : 15 | 16 | 00000000 00000000 00000000 00000000 17 | ******zy xwvutsrq ponmlkji hgfedcba 18 | 19 | Launch the program without arguments or with the '-h' flag activated must print 20 | an usage on the standard output, as shown in the following examples. 21 | 22 | A wrong option must print "Invalid Option" followd by a newline. 23 | 24 | Examples : 25 | $>./options 26 | options: abcdefghijklmnopqrstuvwxyz 27 | $>./options -abc -ijk 28 | 00000000 00000000 00000111 00000111 29 | $>./options -z 30 | 00000010 00000000 00000000 00000000 31 | $>./options -abc -hijk 32 | options: abcdefghijklmnopqrstuvwxyz 33 | $>./options -% 34 | Invalid Option 35 | -------------------------------------------------------------------------------- /3-3-ft_range/ft_range.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_range.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 16:43:01 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 16:58:11 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int *ft_range(int start, int end) 16 | { 17 | int i; 18 | int size; 19 | int *tab; 20 | 21 | i = 0; 22 | size = end - start; 23 | tab = (int*)malloc(sizeof(*tab) * size + 1); 24 | if (size <= 0) 25 | tab = 0; 26 | while (start <= end) 27 | { 28 | tab[i] = start; 29 | i++; 30 | start++; 31 | } 32 | return (tab); 33 | } 34 | -------------------------------------------------------------------------------- /0-1-maff_alpha/maff_alpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maff_alpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/01 21:29:02 by exam #+# #+# */ 9 | /* Updated: 2017/12/13 15:51:41 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void affiche(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | int main(void) 21 | { 22 | int a; 23 | int b; 24 | 25 | a = 'a'; 26 | b = 'B'; 27 | while (a <= 'y') 28 | { 29 | while (b <= 'Z') 30 | { 31 | affiche(a); 32 | a += 2; 33 | affiche(b); 34 | b += 2; 35 | } 36 | } 37 | affiche('\n'); 38 | return (0); 39 | } 40 | -------------------------------------------------------------------------------- /1-0-rev_print/rev_print.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rev_print.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/06 16:29:56 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/13 16:11:08 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | int main(int argc, char **argv) 21 | { 22 | int i; 23 | 24 | i = 0; 25 | if (argc == 2) 26 | { 27 | while (argv[1][i]) 28 | i++; 29 | while (i > 0) 30 | { 31 | ft_putchar(argv[1][i - 1]); 32 | i--; 33 | } 34 | } 35 | ft_putchar('\n'); 36 | return (0); 37 | } 38 | -------------------------------------------------------------------------------- /4-1-brainfuck/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : brainfuck 2 | Expected files : *.c, *.h 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a Brainfuck interpreter program. 7 | The source code will be given as first parameter. 8 | The code will always be valid, with no more than 4096 operations. 9 | Brainfuck is a minimalist language. It consists of an array of bytes 10 | (in our case, let's say 2048 bytes) initialized to zero, 11 | and a pointer to its first byte. 12 | 13 | Every operator consists of a single character : 14 | - '>' increment the pointer ; 15 | - '<' decrement the pointer ; 16 | - '+' increment the pointed byte ; 17 | - '-' decrement the pointed byte ; 18 | - '.' print the pointed byte on standard output ; 19 | - '[' go to the matching ']' if the pointed byte is 0 (while start) ; 20 | - ']' go to the matching '[' if the pointed byte is not 0 (while end). 21 | 22 | Any other character is a comment. 23 | 24 | Examples: 25 | 26 | $>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-] 27 | >++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e 28 | Hello World!$ 29 | $>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e 30 | Hi$ 31 | $>./brainfuck | cat -e 32 | $ 33 | -------------------------------------------------------------------------------- /options/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : options 2 | Expected files : *.c *.h 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire un programme qui prends un nombre indéfini d'arguments pouvant être des 7 | options et qui écrit sur le sortie standard une représentation de ces options sous 8 | forme de groupes d'octets suivi d'une newline. 9 | 10 | Une option est un argument défini par un caractere ouvrant '-' et qui peut prendre 11 | plusieurs caractères consécutifs pouvant être : abcdefghijklmnopqrstuvwxyz 12 | 13 | Toutes les options sont stockées dans un seul int et chaque option représente 14 | un bit de l'int, tel que : 15 | 16 | 00000000 00000000 00000000 00000000 17 | ******zy xwvutsrq ponmlkji hgfedcba 18 | 19 | Lancer le programme sans argument ou avec le flag '-h' activé doit afficher sur 20 | la sortie standard, un usage du programme comme montré dans les exemples. 21 | 22 | Une option non disponible doit renvoyer "Invalid Option" suivi d'une newline. 23 | 24 | Exemples : 25 | $>./options 26 | options: abcdefghijklmnopqrstuvwxyz 27 | $>./options -abc -ijk 28 | 00000000 00000000 00000111 00000111 29 | $>./options -z 30 | 00000010 00000000 00000000 00000000 31 | $>./options -abc -hijk 32 | options: abcdefghijklmnopqrstuvwxyz 33 | $>./options -% 34 | Invalid Option 35 | -------------------------------------------------------------------------------- /4-0-check_mate/check_mate.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* check_mate.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/09 12:03:41 by exam #+# #+# */ 9 | /* Updated: 2018/01/09 12:20:12 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void check_mate(char **plateau, int taille) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (i < taille) 21 | { 22 | write(1, plateau[i], taille); 23 | write(1, "\n", 1); 24 | i++; 25 | } 26 | } 27 | 28 | int main(int ac, char **av) 29 | { 30 | if (ac > 2) 31 | { 32 | check_mate(++av, ac - 1); 33 | } 34 | else 35 | write(1, "\n", 1); 36 | return (0); 37 | } 38 | -------------------------------------------------------------------------------- /4-1-brainfuck/subject.ro.txt: -------------------------------------------------------------------------------- 1 | Exercitiu : brainfuck 2 | Fisiere de iesire : *.c, *.h 3 | Functii autorizate : write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Scrieti un interpretor de programe numit Brainfuck. 7 | Codul sursa va fi dat ca primul argument. 8 | Codul va fi mereu valid, cu cel mult 4096 operatii. 9 | Barinfuck este un limbaj minimal. Contine un vector de bytes 10 | (pentru acest exercitiu, 2048 bytes) initializati cu zero, si 11 | un pointer spre primul byte. 12 | 13 | Fiecare operator consista dintr-un singur caracter: 14 | - '>' incrementeaza pointerul ; 15 | - '<' decrementeaza pointerul ; 16 | - '+' incrementeaza byte-ul la care pointeaza ; 17 | - '-' decrementeaza byte-ul la care pointeaza ; 18 | - '.' printeaza la iesirea standard byte-ul spre care pointeaza ; 19 | - '[' du-te la perechea ']' byte-ul la care pointeaza e 0 (while start) ; 20 | - ']' du-te la perechea '[' byte-ul la care pointeaza nu e 0 (while end). 21 | 22 | Orice alt caracter este un comentariu. 23 | 24 | Examples: 25 | 26 | $>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-] 27 | >++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e 28 | Hello World!$ 29 | $>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e 30 | Hi$ 31 | $>./brainfuck | cat -e 32 | $ 33 | -------------------------------------------------------------------------------- /options/options.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* options.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/05/29 11:24:34 by exam #+# #+# */ 9 | /* Updated: 2018/05/29 11:38:14 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int options() 16 | 17 | a = ascii 97 18 | z = ascii 122 19 | 00000000 00000000 00000000 00000000 20 | ******zy xwvutsrq ponmlkji hgfedcba 21 | 22 | tab[6] = z 23 | tab[7] = y 24 | tab[8] = ' ' 25 | tab[9] = x 26 | tab[34] = a 27 | 28 | int is_alpha(char c) 29 | { 30 | return (c >= 'a' && c <= 'z'); 31 | } 32 | 33 | si ac == 1 || *s == h affiche usage 34 | si *s == - && !is_alpha(*++s) affiche Invalid Option 35 | sinon 36 | 37 | -------------------------------------------------------------------------------- /4-1-brainfuck/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : brainfuck 2 | Expected files : *.c, *.h 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme capable d'interpréter du Brainfuck. 7 | Le code source sera passé en premier paramètre. 8 | Le code transmis sera toujours valide, et ne comportera pas plus de 4096 opérations. 9 | Le Brainfuck est un langage minimaliste constitué d'un tableau d'octets 10 | (dans le cadre de cet exercice, 2048 octets) tous initialisés à 0, 11 | et d'un pointeur sur son premier octet. 12 | 13 | Voici les différents opérateurs du Brainfuck : 14 | - '>' incrémente le pointeur ; 15 | - '<' décrémente le pointeur ; 16 | - '+' incrémente l'octet pointé ; 17 | - '-' décrémente l'octet pointé ; 18 | - '.' affiche l'octet pointé sur la sortie standard ; 19 | - '[' va au ']' correspondant si l'octet pointé est égal à 0 (début de boucle) ; 20 | - ']' va au '[' correspondant si l'octet pointé est différent de 0 (fin de boucle). 21 | 22 | Tout autre caractère est un commentaire. 23 | 24 | Exemples: 25 | 26 | $>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-] 27 | >++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e 28 | Hello World!$ 29 | $>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e 30 | Hi$ 31 | $>./brainfuck | cat -e 32 | $ 33 | -------------------------------------------------------------------------------- /4-0-sort_list/sort_list.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* sort_list.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/04/11 11:34:01 by lsauvage #+# #+# */ 9 | /* Updated: 2018/04/11 12:34:32 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "list.h" 15 | 16 | t_list *sort_list(t_list *lst, int (*cmp)(int, int)) 17 | { 18 | t_list *tmp; 19 | int temp; 20 | 21 | tmp = lst; 22 | temp = 0; 23 | while (lst->next != NULL) 24 | { 25 | if ((*cmp)(lst->data, lst->next->data) == 0) 26 | { 27 | temp = lst->data; 28 | lst->data = lst->next->data; 29 | lst->next->data = temp; 30 | lst = tmp; 31 | } 32 | else 33 | lst = lst->next; 34 | } 35 | lst = tmp; 36 | return (lst); 37 | } 38 | -------------------------------------------------------------------------------- /5-0-cycle_detector/cycle_detector.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* cycle_detector.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/04/11 16:53:59 by lsauvage #+# #+# */ 9 | /* Updated: 2018/04/11 17:14:24 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "./list.h" 15 | 16 | int cycle_detector(const t_list *list) 17 | { 18 | const t_list *lst1; 19 | const t_list *lst2; 20 | 21 | if (list == NULL) 22 | return (1); 23 | lst1 = list; 24 | lst2 = list; 25 | while (1) 26 | { 27 | lst1 = lst1->next; 28 | if (lst2->next != NULL) 29 | lst2 = lst2->next->next; 30 | else 31 | return (0); 32 | if (lst1 == NULL || lst2 == NULL) 33 | return (0); 34 | if (lst1 == lst2) 35 | return (1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /2-1-do_op/do_op.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* do_op.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/09/22 16:16:21 by exam #+# #+# */ 9 | /* Updated: 2017/09/22 16:38:03 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int main(int argc, char **argv) 17 | { 18 | if (argc == 4) 19 | { 20 | if (argv[2][0] == '*') 21 | printf("%d", atoi(argv[1]) * atoi(argv[3])); 22 | if (argv[2][0] == '/') 23 | printf("%d", atoi(argv[1]) / atoi(argv[3])); 24 | if (argv[2][0] == '+') 25 | printf("%d", atoi(argv[1]) + atoi(argv[3])); 26 | if (argv[2][0] == '-') 27 | printf("%d", atoi(argv[1]) - atoi(argv[3])); 28 | if (argv[2][0] == '%') 29 | printf("%d", atoi(argv[1]) % atoi(argv[3])); 30 | } 31 | printf("\n"); 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /4-0-ft_list_remove_if/ft_list_remove_if.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_list_remove_if.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/18 17:43:31 by lsauvage #+# #+# */ 9 | /* Updated: 2018/02/12 16:26:01 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft_list.h" 15 | 16 | void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)()) 17 | { 18 | t_list *tmp; 19 | t_list *i; 20 | while (*begin_list && cmp((*begin_list)->data, data_ref) == 0) 21 | { 22 | tmp = *begin_list; 23 | *begin_list = (*begin_list)->next; 24 | free(tmp); 25 | } 26 | i = *begin_list; 27 | while (i && i->next) 28 | { 29 | if (cmp(i->next->data, data_ref) == 0) 30 | { 31 | tmp = i->next; 32 | i->next = tmp->next; 33 | free(tmp); 34 | } 35 | if (i->next) 36 | i = i->next; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /4-0-check_mate/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : check_mate 2 | Expected files : *.c, *.h 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program who takes rows of a chessboard in argument and check if your 7 | King is in a check position. 8 | 9 | Chess is played on a chessboard, a squared board of 8-squares length with 10 | specific pieces on it : King, Queen, Bishop, Knight, Rook and Pawns. 11 | For this exercice, you will only play with Pawns, Bishops, Rooks and Queen... 12 | and obviously a King. 13 | 14 | Each piece have a specific method of movement, and all patterns of capture are 15 | detailled in the examples.txt file. 16 | 17 | A piece can capture only the first ennemy piece it founds on its capture 18 | patterns. 19 | 20 | The board have a variable size but will remains a square. There's only one King 21 | and all other pieces are against it. All other characters except those used for 22 | pieces are considered as empty squares. 23 | 24 | The King is considered as in a check position when an other enemy piece can 25 | capture it. When it's the case, you will print "Success" on the standard output 26 | followed by a newline, otherwise you will print "Fail" followed by a newline. 27 | 28 | If there is no arguments, the program will only print a newline. 29 | 30 | Examples: 31 | 32 | $> ./chessmate '..' '.K' | cat -e 33 | Fail$ 34 | $> ./check_mate 'R...' '.K..' '..P.' '....' | cat -e 35 | Success$ 36 | $> ./chessmate 'R...' 'iheK' '....' 'jeiR' | cat -e 37 | Success$ 38 | $> ./chessmate | cat -e 39 | $ 40 | $> 41 | -------------------------------------------------------------------------------- /5-1-rpn_calc/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rpn_calc 2 | Expected files : *.c, *.h 3 | Allowed functions: atoi, printf, write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string which contains an equation written in 7 | Reverse Polish notation (RPN) as its first argument, evaluates the equation, and 8 | prints the result on the standard output followed by a newline. 9 | 10 | Reverse Polish Notation is a mathematical notation in which every operator 11 | follows all of its operands. In RPN, every operator encountered evaluates the 12 | previous 2 operands, and the result of this operation then becomes the first of 13 | the two operands for the subsequent operator. Operands and operators must be 14 | spaced by at least one space. 15 | 16 | You must implement the following operators : "+", "-", "*", "/", and "%". 17 | 18 | If the string isn't valid or there isn't exactly one argument, you must print 19 | "Error" on the standard output followed by a newline. 20 | 21 | All the given operands must fit in a "int". 22 | 23 | Examples of formulas converted in RPN: 24 | 25 | 3 + 4 >> 3 4 + 26 | ((1 * 2) * 3) - 4 >> 1 2 * 3 * 4 - ou 3 1 2 * * 4 - 27 | 50 * (5 - (10 / 9)) >> 5 10 9 / - 50 * 28 | 29 | Here's how to evaluate a formula in RPN: 30 | 31 | 1 2 * 3 * 4 - 32 | 2 3 * 4 - 33 | 6 4 - 34 | 2 35 | 36 | Or: 37 | 38 | 3 1 2 * * 4 - 39 | 3 2 * 4 - 40 | 6 4 - 41 | 2 42 | 43 | Examples: 44 | 45 | $> ./rpn_calc "1 2 * 3 * 4 +" | cat -e 46 | 10$ 47 | $> ./rpn_calc "1 2 3 4 +" | cat -e 48 | Error$ 49 | $> ./rpn_calc |cat -e 50 | Error$ 51 | -------------------------------------------------------------------------------- /4-0-check_mate/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : check_mate 2 | Expected files : *.c, *.h 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire un programme qui prendra en arguments les lignes d'un plateau de jeu 7 | d'échecs, et verifie si le Roi est en échec ou non par rapport aux autres 8 | pièces en jeu. 9 | 10 | Pour rappel, un jeu d'échecs est composé d'un plateau carré de 8 cases de coté 11 | et est composé de pièces spécifiques: Roi, Reine, Fou, Cavalier, Tour et Pion. 12 | Pour cet exercice, nous ne garderons que les Pions, Fous, Tours et Dames, en 13 | plus du Roi. 14 | 15 | Chaque pièce peut se déplacer que selon un schéma précis et les patterns de 16 | captures sont détaillés dans l'exemple fourni. 17 | 18 | Une piece ne peut capturer que la premiere piece possible sur leur trajectoire 19 | de capture. 20 | 21 | Le plateau peut être de taille différente que le plateau classique, mais sera 22 | TOUJOURS carré. Il ne peut y avoir qu'un seul Roi et toutes les autres 23 | pièces seront contre lui. Tout autre caractere hormis ceux utilises pour les 24 | pieces d'echec sera considere comme une case vide. 25 | 26 | Le roi est considéré comme en échec si une pièce adverse est en position pour 27 | le capturer. Si il est en échec, vous devrez afficher "Success" suivi d'une new- 28 | line, sinon il affichera "Fail" suivi d'une newline. 29 | 30 | Si aucun argument n'est fourni, le programme affichera une newline. 31 | 32 | Exemples: 33 | 34 | $> ./check_mate '..' '.K' | cat -e 35 | Fail$ 36 | $> ./check_mate 'R...' '.K..' '..P.' '....' | cat -e 37 | Success$ 38 | $> ./check_mate | cat -e 39 | $ 40 | $> 41 | -------------------------------------------------------------------------------- /2-0-alpha_mirror/alpha_mirror.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* alpha_mirror.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/12 10:48:41 by exam #+# #+# */ 9 | /* Updated: 2017/12/12 17:04:29 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | /* 16 | ** Pour l'effet mirroir, on soustrait le code ASCII du caractere rencontre dans 17 | ** la chaine a : - 219 si c'est une min 'a' + 'z' = 97 + 122 = 219 18 | ** - 155 si c'est une MAJ 'A' + 'Z' = 65 + 90 = 155 19 | */ 20 | 21 | void ft_putchar(char c) 22 | { 23 | write(1, &c, 1); 24 | } 25 | 26 | int main(int ac, char **av) 27 | { 28 | int i; 29 | 30 | if (ac == 2) 31 | { 32 | i = 0; 33 | while (av[1][i]) 34 | { 35 | if (av[1][i] >= 'a' && av[1][i] <= 'z') 36 | ft_putchar(219 - av[1][i]); 37 | else if (av[1][i] >= 'A' && av[1][i] <= 'Z') 38 | ft_putchar(155 - av[1][i]); 39 | else 40 | ft_putchar(av[1][i]); 41 | i++; 42 | } 43 | } 44 | ft_putchar('\n'); 45 | return (0); 46 | } 47 | -------------------------------------------------------------------------------- /4-0-rev_wstr/rev_wstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rev_wstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/12 12:32:16 by lsauvage #+# #+# */ 9 | /* Updated: 2018/01/12 15:12:22 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_isblank(int c) 16 | { 17 | return (c == ' ' || c == '\t'); 18 | } 19 | 20 | void rev_wstr(char *s) 21 | { 22 | int wc; 23 | int i; 24 | int len; 25 | int a; 26 | 27 | wc = 0; 28 | i = 0; 29 | while (s[i]) 30 | if (!ft_isblank(s[i++]) && (!wc || ft_isblank(s[i - 2]))) 31 | ++wc; 32 | while (s[--i]) 33 | { 34 | if (!ft_isblank(s[i]) && wc--) 35 | { 36 | a = 0; 37 | len = 1; 38 | while (s[i - 1] && !ft_isblank(s[i - 1]) && ++len) 39 | --i; 40 | while (len-- && write(1, &s[i + a++], 1)); 41 | (wc) ? write(1, " ", 1) : 0; 42 | } 43 | } 44 | } 45 | 46 | int main(int ac, char **av) 47 | { 48 | if (ac == 2 && *av[1]) 49 | rev_wstr(av[1]); 50 | write(1, "\n", 1); 51 | return (0); 52 | } 53 | -------------------------------------------------------------------------------- /4-0-rev_wstr/rev_wstr2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rev_wstr2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/31 11:29:37 by lsauvage #+# #+# */ 9 | /* Updated: 2018/02/01 14:48:22 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_isblank(int c) 16 | { 17 | return (c == ' ' || c == '\t'); 18 | } 19 | 20 | int ft_strlen(char *str) 21 | { 22 | int i; 23 | 24 | i = 0; 25 | while (str[i]) 26 | i++; 27 | return (i); 28 | } 29 | 30 | void rev_wstr(char *str) 31 | { 32 | int wc; 33 | int i; 34 | int len; 35 | int a; 36 | 37 | wc = 1; 38 | i = 0; 39 | a = 0; 40 | len = ft_strlen(str); 41 | while (--len && !ft_isblank(str[len])) 42 | i++; 43 | while(a < i) 44 | { 45 | write(1, str[len], i); 46 | a++; 47 | } 48 | } 49 | 50 | int main(int ac, char **av) 51 | { 52 | if (ac == 2 && *av[1]) 53 | rev_wstr(av[1]); 54 | write(1, "\n", 1); 55 | return (0); 56 | } 57 | -------------------------------------------------------------------------------- /3-0-ft_rrange/ft_rrange.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rrange.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/09 10:04:58 by exam #+# #+# */ 9 | /* Updated: 2018/01/09 11:47:42 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_abs(int nb) 16 | { 17 | return (nb < 0 ? -nb : nb); 18 | } 19 | 20 | int *ft_rrange(int start, int end) 21 | { 22 | int size; 23 | int *tab; 24 | int i; 25 | 26 | size = 0; 27 | if (start > 0 && end < 0) 28 | size = ft_abs(end) + ft_abs(start) + 1; 29 | else if (start < 0 && end < 0) 30 | size = ft_abs(end) - ft_abs(start) + 1; 31 | else 32 | size = ft_abs(end) - start + 1; 33 | tab = (int *)malloc(sizeof(size)); 34 | i = 0; 35 | if (end > start) 36 | { 37 | while (end > start) 38 | { 39 | tab[i] = end; 40 | i++; 41 | end--; 42 | } 43 | } 44 | else if (end < start) 45 | { 46 | while (end < start) 47 | { 48 | tab[i] = end; 49 | i++; 50 | end++; 51 | } 52 | } 53 | tab[i] = end; 54 | return (tab); 55 | } 56 | -------------------------------------------------------------------------------- /3-0-lcm/lcm.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* lcm.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/12 11:38:02 by exam #+# #+# */ 9 | /* Updated: 2017/12/12 13:20:16 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | unsigned int ft_min(unsigned int a, unsigned int b) 14 | { 15 | return (a < b ? a : b); 16 | } 17 | 18 | unsigned int ft_max(unsigned int a, unsigned int b) 19 | { 20 | return (a > b ? a : b); 21 | } 22 | 23 | unsigned int hcf(unsigned int a, unsigned int b) 24 | { 25 | unsigned int i; 26 | unsigned int pgcd; 27 | 28 | i = 1; 29 | pgcd = 1; 30 | while (i <= ft_min(a, b)) 31 | { 32 | if (a % i == 0 && b % i == 0) 33 | pgcd = i; 34 | i++; 35 | } 36 | return (pgcd); 37 | } 38 | 39 | unsigned int lcm(unsigned int a, unsigned int b) 40 | { 41 | unsigned int i; 42 | unsigned int ppcm; 43 | 44 | i = 1; 45 | ppcm = 1; 46 | if (a == 0 || b == 0) 47 | ppcm = 0; 48 | else if (a % b == 0 || b % a == 0) 49 | ppcm = ft_max(a, b); 50 | else 51 | ppcm = (a * b) / hcf(a, b); 52 | return (ppcm); 53 | } 54 | -------------------------------------------------------------------------------- /flood_fill/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : flood_fill 2 | Expected files : *.c, *.h 3 | Allowed functions: - 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a char ** as a 2-dimensional array of char, a 7 | t_point as the dimensions of this array and a t_point as the starting point. 8 | 9 | Starting from the given 'begin' t_point, this function 'colors' an entire zone 10 | by replacing characters inside by the character 'F'. A zone is an ensemble of 11 | the same character delimitated horizontally and vertically by other characters. 12 | 13 | The flood_fill function won't 'color' in diagonal. 14 | 15 | The flood_fill function will be prototyped like this: 16 | void flood_fill(char **tab, t_point size, t_point begin); 17 | 18 | The t_point structure is available inside the "t_point.h" file attached to this 19 | assignment. We will use our "t_point.h" for graduation. 20 | 21 | Example : 22 | 23 | $> cat test_main.c 24 | #include "test_functions.h" 25 | #include "flood_fill.h" 26 | 27 | int main(void) 28 | { 29 | char **area; 30 | t_point size = { 8, 5 }; 31 | t_point begin = { 2, 2 }; 32 | char *zone[] = { 33 | "11111111", 34 | "10001001", 35 | "10010001", 36 | "10110001", 37 | "11100001", 38 | }; 39 | 40 | area = make_area(zone); 41 | print_tab(area); 42 | flood_fill(area, size, begin); 43 | putc('\n'); 44 | print_tab(area); 45 | return (0); 46 | } 47 | 48 | $> gcc flood_fill.c test_main.c test_functions.c -o flood_fill ; ./flood_fill 49 | 1 1 1 1 1 1 1 1 50 | 1 0 0 0 1 0 0 1 51 | 1 0 0 1 0 0 0 1 52 | 1 0 1 0 0 0 0 1 53 | 1 1 0 0 0 0 0 0 54 | 55 | 1 1 1 1 1 1 1 1 56 | 1 F F F 1 0 0 1 57 | 1 F F 1 0 0 0 1 58 | 1 F 1 0 0 0 0 1 59 | 1 1 0 0 0 0 0 0 60 | $> 61 | -------------------------------------------------------------------------------- /4-1-fprime/fprime.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* fprime.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/09 12:29:43 by exam #+# #+# */ 9 | /* Updated: 2018/01/09 13:55:01 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_is_prime(int nb) 17 | { 18 | int i; 19 | 20 | i = 2; 21 | if (nb <= 0) 22 | return (0); 23 | while (i <= nb / i) 24 | { 25 | if (nb % i == 0) 26 | return (0); 27 | i++; 28 | } 29 | return (1); 30 | } 31 | 32 | void fprime(int nb) 33 | { 34 | int i; 35 | if (ft_is_prime(nb)) 36 | printf("%d", nb); 37 | else 38 | { 39 | i = 2; 40 | while (i <= nb) 41 | { 42 | if (ft_is_prime(i)) 43 | { 44 | while (nb % i == 0) 45 | { 46 | nb = nb / i; 47 | if (nb != 1) 48 | printf("%d*", i); 49 | else 50 | printf("%d", i); 51 | } 52 | } 53 | i++; 54 | } 55 | } 56 | } 57 | 58 | int main(int ac, char **av) 59 | { 60 | int i; 61 | 62 | i = 0; 63 | if (ac == 2) 64 | { 65 | fprime(atoi(av[1])); 66 | } 67 | printf("\n"); 68 | return(0); 69 | } 70 | -------------------------------------------------------------------------------- /4-0-ft_split/ft_split.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_split.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/12 13:27:25 by exam #+# #+# */ 9 | /* Updated: 2017/12/12 13:54:29 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i]) 19 | i++; 20 | return (i); 21 | } 22 | 23 | int ft_isspace(char c) 24 | { 25 | return (c == ' ' || c == '\n' || c == '\t'); 26 | } 27 | 28 | int ft_isprint(char c) 29 | { 30 | return (c >= ' ' && c <= '~'); 31 | } 32 | 33 | int ft_isgraph(char c) 34 | { 35 | return (c > ' ' && c <= '~'); 36 | } 37 | 38 | char **ft_split(char *str) 39 | { 40 | int i; 41 | int j; 42 | int k; 43 | char **tab; 44 | 45 | i = 0; 46 | j = 0; 47 | k = 0; 48 | tab = (char **)malloc(sizeof((char) * ft_strlen(str) + 1)); 49 | while (str[i]) 50 | { 51 | if (ft_isgraph(str[i])) 52 | { 53 | tab[j][k] = str[i]; 54 | i++; 55 | k++; 56 | } 57 | if (ft_isspace(str[i])) 58 | { 59 | i++; 60 | j++; 61 | k = 0; 62 | } 63 | } 64 | tab[j + 1] = NULL; 65 | return (tab); 66 | } 67 | -------------------------------------------------------------------------------- /4-0-moment/moment_fail.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* moment_fail.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/04/16 15:19:36 by lsauvage #+# #+# */ 9 | /* Updated: 2018/05/29 16:21:31 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *moment(unsigned int duration) 17 | { 18 | char *ret; 19 | unsigned int converter[5] = {60, 3600, 86400, 2592000, 31104000}; 20 | char **units; 21 | int i; 22 | 23 | if (!(units = (char **)malloc(sizeof(char *) * 5))) 24 | { 25 | return (NULL); 26 | } 27 | ret = NULL; 28 | i = 0; 29 | units[0] = "seconds"; 30 | units[1] = "minutes"; 31 | units[2] = "hours"; 32 | units[3] = "days"; 33 | units[4] = "months"; 34 | while (i < 5) 35 | { 36 | duration /= converter[i]; 37 | if (duration == 0 || duration < converter[i]) 38 | { 39 | return (units[i]); 40 | } 41 | i++; 42 | } 43 | return (0); 44 | } 45 | 46 | int main(int ac, char **av) 47 | { 48 | if (ac == 2) 49 | { 50 | printf("secondes : %d\n", atoi(av[1])); 51 | printf("duree : %s\n", moment(atoi(av[1]))); 52 | } 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /flood_fill/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : flood_fill 2 | Expected files : *.c, *.h 3 | Allowed functions: - 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrivez une fonction qui prends en paramètres un char** qui sera une aire à 2 7 | dimensions, une structure de type t_point qui donnera la longueur et la largeur 8 | de cette aire, et une structure de type t_point symbolisant le point de départ. 9 | 10 | Cette fonction devra 'colorer' une zone de l'aire donnée en argument, en 11 | remplaçant les caractères de cette zone par des 'F'. Une zone est un ensemble 12 | de mêmes caractères, délimitée horizontalement et verticalement par d'autres 13 | caractères. 14 | 15 | La fonction flood_fill ne 'colore' pas en diagonale. 16 | 17 | La fonction flood_fill devra être prototypée comme suit : 18 | void flood_fill(char **tab, t_point size, t_point begin); 19 | 20 | La structure t_point est présente dans le fichier "t_point.h" mis en annexe 21 | de ce sujet. Nous utiliserons notre "t_point.h" pour le rendu. 22 | 23 | Exemple: 24 | 25 | $>cat test_main.c 26 | #include "test_functions.h" 27 | #include "t_point.h" 28 | 29 | int main(void) 30 | { 31 | char **area; 32 | t_point size = { 8, 5 }; 33 | t_point begin = { 2, 2 }; 34 | char *zone[] = { 35 | "11111111", 36 | "10001001", 37 | "10010001", 38 | "10110001", 39 | "11100001", 40 | }; 41 | 42 | area = make_area(zone); 43 | print_tab(area); 44 | flood_fill(area, size, begin); 45 | putc('\n'); 46 | print_tab(area); 47 | return (0); 48 | } 49 | 50 | $> gcc flood_fill.c test_main.c test_functions.c -o flood_fill ; ./flood_fill 51 | 1 1 1 1 1 1 1 1 52 | 1 0 0 0 1 0 0 1 53 | 1 0 0 1 0 0 0 1 54 | 1 0 1 0 0 0 0 1 55 | 1 1 0 0 0 0 0 0 56 | 57 | 1 1 1 1 1 1 1 1 58 | 1 F F F 1 0 0 1 59 | 1 F F 1 0 0 0 1 60 | 1 F 1 0 0 0 0 1 61 | 1 1 0 0 0 0 0 0 62 | $> 63 | -------------------------------------------------------------------------------- /3-0-ft_atoi_base/ft_atoi_base.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi_base.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/19 10:02:49 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/19 12:07:24 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_isspace(int c) 14 | { 15 | return (c == ' ' || c == '\n' || c == '\t' 16 | || c == '\v' || c == '\r' || c == '\f'); 17 | } 18 | 19 | int test_base(const char c) 20 | { 21 | int nb; 22 | 23 | if (c >= '0' && c >= '9') 24 | nb = c - '0'; 25 | else if (c >= 'a' && c <= 'z') 26 | nb = c - 'a' + 10; 27 | else if (c >= 'A' && c <= 'Z') 28 | nb = c - 'A' + 10; 29 | else 30 | nb = -1; 31 | return (nb); 32 | } 33 | 34 | int ft_atoi_base(const char *str, int str_base) 35 | { 36 | int i; 37 | int neg; 38 | int toi; 39 | int current; 40 | 41 | i = 0; 42 | toi = 0; 43 | while (ft_isspace(str[i])) 44 | i++; 45 | neg = (str[i] == '-' ? -1 : 1); 46 | if (str[i] == '-' || str[i] == '+') 47 | i++; 48 | current = test_base(str[i]); 49 | while (current >= 0 && current < str_base) 50 | { 51 | toi = toi * str_base + current; 52 | i++; 53 | current = test_base(str[i]); 54 | } 55 | return (toi * neg); 56 | } 57 | -------------------------------------------------------------------------------- /biggest_pal/biggest_pal.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* biggest_pal.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aait-ihi +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 15:10:51 by aait-ihi #+# #+# */ 9 | /* Updated: 2019/06/15 17:17:35 by aait-ihi ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(const char *str) 16 | { 17 | size_t size = 0; 18 | while (str && *str++) 19 | size++; 20 | return (size); 21 | } 22 | 23 | void biggest_pal(char *str, int size,int posibilities) 24 | { 25 | int i, j, c = 0; 26 | 27 | while(c < posibilities) 28 | { 29 | i = -c; 30 | j = size - c - 1; 31 | while (i < j && str[i] == str[j]) 32 | { 33 | i++; 34 | j--; 35 | } 36 | if(str[i] == str[j]) 37 | { 38 | write(1, &str[-c], size); 39 | return ; 40 | } 41 | c++; 42 | } 43 | if(str[1]) 44 | biggest_pal(str + 1, size - 1, posibilities + 1); 45 | } 46 | 47 | int main(int ac, char *av[]) 48 | { 49 | if (ac == 2) 50 | biggest_pal(av[1], ft_strlen(av[1]), 1); 51 | write(1, "\n", 1); 52 | } 53 | -------------------------------------------------------------------------------- /5-1-rpn_calc/rpn_calc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rpn_calc.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/05/29 10:41:06 by exam #+# #+# */ 9 | /* Updated: 2018/05/29 11:17:16 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int is_space(char c) 18 | { 19 | return (c == ' '); 20 | } 21 | 22 | int is_digit(char c) 23 | { 24 | return (c <= '1' && c <= '9'); 25 | } 26 | 27 | int is_oper(char c) 28 | { 29 | return (c == '+' || c == '-' || c == '*' || c == '/' || c == '%'); 30 | } 31 | 32 | int do_op(int a, int b, char c) 33 | { 34 | if (c == '+') 35 | return (a + b); 36 | if (c == '-') 37 | return (a - b); 38 | if (c == '*') 39 | return (a * b); 40 | if (c == '/') 41 | return (a / b); 42 | if (c == '%') 43 | return (a % b); 44 | else 45 | return (0); 46 | } 47 | 48 | int rpn_calc(char *s) 49 | { 50 | int res; 51 | 52 | res = 0; 53 | while (*s) 54 | { 55 | if (is_oper(*s)) 56 | res += do_op(atoi(s - 4), atoi(s - 2), *s); 57 | s++; 58 | } 59 | return (res); 60 | } 61 | 62 | int main(int ac, char **av) 63 | { 64 | if (ac == 2) 65 | { 66 | printf("%d\n", rpn_calc(av[1])); 67 | } 68 | else 69 | printf("Error\n"); 70 | return (0); 71 | } 72 | -------------------------------------------------------------------------------- /5-0-brackets/brackets.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* brackets.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/05/29 10:22:27 by exam #+# #+# */ 9 | /* Updated: 2018/05/29 11:48:18 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int brackets(char *s) 16 | { 17 | int a; 18 | int c; 19 | int p; 20 | char last; 21 | 22 | a = 0; 23 | c = 0; 24 | p = 0; 25 | while (*s) 26 | { 27 | if (*s == '{') 28 | a++; 29 | if (*s == '[') 30 | c++; 31 | if (*s == '(') 32 | p++; 33 | if (*s == '}') 34 | { 35 | --a; 36 | if (last == '[' || last == '(') 37 | return (0); 38 | } 39 | if (*s == ']') 40 | { 41 | --c; 42 | if (last == '{' || last == '(') 43 | return (0); 44 | } 45 | if (*s == ')') 46 | { 47 | --p; 48 | if (last == '{' || last == '[') 49 | return (0); 50 | } 51 | if (*s == '{' || *s == '[' || *s == '(' || *s == '}' || *s == ']' 52 | || *s == ')') 53 | last = *s; 54 | s++; 55 | } 56 | return (a == 0 && c == 0 && p == 0); 57 | } 58 | 59 | int main(int ac, char **av) 60 | { 61 | int i; 62 | 63 | i = 1; 64 | if (ac > 1) 65 | { 66 | while (i < ac) 67 | { 68 | if (brackets(av[i])) 69 | write(1, "OK\n", 3); 70 | else 71 | write(1, "Error\n", 6); 72 | i++; 73 | } 74 | } 75 | else 76 | write(1, "\n", 1); 77 | return (0); 78 | } 79 | -------------------------------------------------------------------------------- /4-1-ft_itoa/ft_itoa.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_itoa.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/03/22 18:04:44 by exam #+# #+# */ 9 | /* Updated: 2018/03/26 14:01:06 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_intlen(int nbr) 17 | { 18 | int len; 19 | 20 | if (nbr == 0) 21 | return (1); 22 | len = 0; 23 | if (nbr < 0) 24 | { 25 | nbr = -nbr; 26 | len = ft_intlen(nbr) + 1; 27 | } 28 | else 29 | { 30 | while (nbr > 0) 31 | { 32 | len += 1; 33 | nbr = nbr / 10; 34 | } 35 | } 36 | return (len); 37 | } 38 | 39 | char *ft_itoa(int nbr) 40 | { 41 | char *toa; 42 | int len; 43 | 44 | len = ft_intlen(nbr); 45 | toa = (char *)malloc(sizeof(char) * len + 1); 46 | toa[len + 1] = '\0'; 47 | if (nbr == (-2 ^ 31) || nbr == (2^31) - 1) 48 | { 49 | return (0); 50 | } 51 | if (nbr < 0) 52 | { 53 | nbr = -nbr; 54 | while (len > 0) 55 | { 56 | toa[len - 1] = nbr % 10 + '0'; 57 | nbr /= 10; 58 | len--; 59 | } 60 | toa[0] = '-'; 61 | } 62 | else 63 | { 64 | while (len > 0) 65 | { 66 | toa[len - 1] = nbr % 10 + '0'; 67 | nbr /= 10; 68 | len--; 69 | } 70 | } 71 | return (toa); 72 | } 73 | 74 | int main(int ac, const char *av[]) 75 | { 76 | if (ac == 2) 77 | { 78 | printf("ItoA : %s\n", ft_itoa(atoi(av[1]))); 79 | } 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /5-1-rpn_calc/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rpn_calc 2 | Expected files : *.c, *.h 3 | Allowed functions: atoi, printf, write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrivez un programme qui prend en premier argument une chaine de caractères 7 | correspondant à une équation écrite en Notation Polonaise Inverse ou NPI, 8 | l'évalue et retourne le résultat sur la sortie standard suivi d'une newline. 9 | 10 | La Notation Polonaise Inverse est un système d'écriture d'opérations arithméti- 11 | ques qui consiste à placer les opérandes avant les opérateurs de telle 12 | sorte que pour chaque opérateur rencontré, les 2 opérandes précédents soient 13 | évalués et le résultat placé en lieu et place dans l'ordre de calcul. Les 14 | opérandes et les opérateurs doivent avoir au moins un espace entre eux. 15 | 16 | Vous devrez implémenter les opérateurs "+", "-", "*", "/" et "%". 17 | 18 | Si la chaine de caractères n'est pas valide ou qu'il n'y a pas un seul argument, 19 | vous devrez afficher "Error" sur la sortie standard, suivie d'une newline. 20 | 21 | Tous les opérandes de la chaine de caracteres doivent pouvoir etre contenus 22 | dans un int. 23 | 24 | Exemple de formules converties en NPI : 25 | 26 | 3 + 4 >> 3 4 + 27 | ((1 * 2) * 3) - 4 >> 1 2 * 3 * 4 - ou 3 1 2 * * 4 - 28 | 50 * (5 - (10 / 9)) >> 5 10 9 / - 50 * 29 | 30 | Décomposition d'un calcul en NPI : 31 | 32 | 1 2 * 3 * 4 - (On évalue "1 2 *" et on remplace l'ensemble par 2) 33 | 2 3 * 4 - (On évalue "2 3 *" et on remplace l'ensemble par 6) 34 | 6 4 - (On évalue "6 4 -" et on remplace l'ensemble par 2) 35 | 2 36 | 37 | ou 38 | 39 | 3 1 2 * * 4 - (On évalue "1 2 *" et on remplace l'ensemble par 2) 40 | 3 2 * 4 - (On évalue "3 2 *" et on remplace l'ensemble par 6) 41 | 6 4 - (On évalue "6 4 -" et on remplace l'ensemble par 2) 42 | 2 43 | 44 | Exemples : 45 | 46 | $> ./rpn_calc "1 2 * 3 * 4 +" | cat -e 47 | 10$ 48 | $> ./rpn_calc "1 2 3 4 +" | cat -e 49 | Error$ 50 | $> ./rpn_calc |cat -e 51 | Error$ 52 | -------------------------------------------------------------------------------- /2-0-union/union.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* union.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/06 18:47:23 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/06 19:42:38 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | int ft_strlen(char *str) 21 | { 22 | int i; 23 | 24 | i = 0; 25 | if (!str || !*str) 26 | return (0); 27 | while (str[i]) 28 | i++; 29 | return (i); 30 | } 31 | 32 | int main(int argc, char **argv) 33 | { 34 | int i; 35 | int current; 36 | int check; 37 | char tmp[ft_strlen(argv[1]) + ft_strlen(argv[2])]; 38 | 39 | i = 0; 40 | current = 0; 41 | check = 0; 42 | if (argc == 3) 43 | { 44 | while (argv[1][i]) 45 | { 46 | check = 0; 47 | while (check != current) 48 | { 49 | if (tmp[check] == argv[1][i]) 50 | break; 51 | check++; 52 | } 53 | if (check == current) 54 | { 55 | ft_putchar(argv[1][i]); 56 | tmp[current] = argv[1][i]; 57 | current++; 58 | } 59 | i++; 60 | } 61 | i = 0; 62 | while (argv[2][i]) 63 | { 64 | check = 0; 65 | while (check != current) 66 | { 67 | if (tmp[check] == argv[2][i]) 68 | break; 69 | check++; 70 | } 71 | if (check == current) 72 | { 73 | ft_putchar(argv[2][i]); 74 | tmp[current] = argv[2][i]; 75 | current++; 76 | } 77 | i++; 78 | } 79 | } 80 | ft_putchar('\n'); 81 | return (0); 82 | } 83 | -------------------------------------------------------------------------------- /ft_itoa_base.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_itoa_base.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/03/29 15:33:51 by lsauvage #+# #+# */ 9 | /* Updated: 2018/03/29 16:52:44 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | static size_t digit_count(long nb, int base) 17 | { 18 | size_t i; 19 | 20 | i = 0; 21 | while (nb) 22 | { 23 | nb /= base; 24 | i++; 25 | } 26 | return (i); 27 | } 28 | 29 | char *ft_itoa_base(int value, int base) 30 | { 31 | char *ret; 32 | char *tab_base; 33 | int taille; 34 | int i; 35 | int sign; 36 | 37 | if (base < 2 || base > 16) 38 | return (0); 39 | if (base == 10 && value == -2147483648) 40 | return ("-2147483648"); 41 | sign = 0; 42 | if (base == 10 && value < 0) 43 | sign = 1; 44 | if (value < 0) 45 | value = -value; 46 | if (value == 0) 47 | return ("0"); 48 | tab_base = (char *)malloc(sizeof(char) * 17); 49 | tab_base = "0123456789ABCDEF"; 50 | taille = digit_count(value, base); 51 | taille += (sign ? 1 : 0); 52 | ret = (char *)malloc(sizeof(char) * (taille + 1)); 53 | i = 1; 54 | sign ? (ret[0] = '-') : 0; 55 | while (value != 0) 56 | { 57 | ret[taille - i++] = tab_base[value % base]; 58 | value /= base; 59 | } 60 | ret[taille] = '\0'; 61 | return (ret); 62 | } 63 | 64 | int main(int ac, const char **av) 65 | { 66 | if (ac == 3) 67 | { 68 | printf("taille de value : %zu\n", digit_count(atoi(av[1]), atoi(av[2]))); 69 | printf("itoa : %s\n", ft_itoa_base(atoi(av[1]), atoi(av[2]))); 70 | } 71 | return (0); 72 | } 73 | -------------------------------------------------------------------------------- /3-0-rstr_capitalizer/rstr_capitalizer.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rstr_capitalizer.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2017/12/18 16:03:10 by lsauvage #+# #+# */ 9 | /* Updated: 2017/12/18 17:44:20 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write (1, &c, 1); 18 | } 19 | 20 | void ft_putstr(char *str) 21 | { 22 | int i; 23 | 24 | i = 0; 25 | while (str[i]) 26 | { 27 | ft_putchar(str[i]); 28 | i++; 29 | } 30 | } 31 | 32 | int ft_islower(int c) 33 | { 34 | return (c >= 'a' && c <= 'z'); 35 | } 36 | 37 | int ft_isupper(int c) 38 | { 39 | return (c >= 'A' && c <= 'Z'); 40 | } 41 | 42 | int ft_tolower(int c) 43 | { 44 | if (ft_isupper(c)) 45 | return (c + 32); 46 | return (c); 47 | } 48 | 49 | int ft_toupper(int c) 50 | { 51 | if (ft_islower(c)) 52 | return (c - 32); 53 | return (c); 54 | } 55 | 56 | int ft_isspace(int c) 57 | { 58 | return (c == ' ' || c == '\t'); 59 | } 60 | 61 | char *rstr_cap(char *str) 62 | { 63 | int i; 64 | int fin; 65 | 66 | i = 0; 67 | fin = 0; 68 | while (str[fin]) 69 | fin++; 70 | while (i < fin) 71 | { 72 | if (ft_isspace(str[i + 1]) || str[i + 1] == '\0') 73 | str[i] = ft_toupper(str[i]); 74 | else 75 | str[i] = ft_tolower(str[i]); 76 | i++; 77 | } 78 | return (str); 79 | } 80 | 81 | int main(int ac, char **av) 82 | { 83 | int i; 84 | 85 | i = 1; 86 | if (ac < 2) 87 | ft_putchar('\n'); 88 | while (i < ac) 89 | { 90 | ft_putstr(rstr_cap(av[i])); 91 | i++; 92 | ft_putchar('\n'); 93 | } 94 | return (0); 95 | } 96 | -------------------------------------------------------------------------------- /4-0-moment/moment.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* moment.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: exam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/05/15 10:02:48 by exam #+# #+# */ 9 | /* Updated: 2018/05/15 13:03:31 by exam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *s) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (s[i]) 21 | i++; 22 | return (i); 23 | } 24 | 25 | unsigned int ft_uintlen(unsigned int nb) 26 | { 27 | unsigned int i; 28 | 29 | i = 0; 30 | if (nb == 0) 31 | i = 1; 32 | while (nb > 0) 33 | { 34 | nb /= 10; 35 | i++; 36 | } 37 | return (i); 38 | } 39 | 40 | char *ft_strcat(char *s1, char *s2) 41 | { 42 | char *res; 43 | int i; 44 | int j; 45 | 46 | if (!(res = malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1)))) 47 | return (NULL); 48 | i = 0; 49 | j = 0; 50 | while (s1[i]) 51 | res[j++] = s1[i++]; 52 | i = 0; 53 | while (s2[i]) 54 | res[j++] = s2[i++]; 55 | res[j] = '\0'; 56 | return (res); 57 | } 58 | 59 | char *ft_utoa(unsigned int nb) 60 | { 61 | int len; 62 | char *tab; 63 | 64 | len = ft_uintlen(nb); 65 | if (!(tab = malloc(sizeof(char) * len + 1))) 66 | return (NULL); 67 | tab[len] = '\0'; 68 | while (nb != 0) 69 | { 70 | tab[--len] = (nb % 10) + '0'; 71 | nb = nb / 10; 72 | } 73 | return (tab); 74 | } 75 | 76 | char *moment(unsigned int duration) 77 | { 78 | if (duration == 0) 79 | return ("0 seconds ago."); 80 | else if (duration == 1) 81 | return ("1 second ago."); 82 | else if (duration < 60) 83 | return (ft_strcat(ft_utoa(duration), " seconds ago.")); 84 | else if (duration < 120) 85 | return ("1 minute ago."); 86 | else if (duration < 3600) 87 | return (ft_strcat(ft_utoa(duration / 60), " minutes ago.")); 88 | else if (duration < 7200) 89 | return ("1 hour ago."); 90 | else if (duration < 86400) 91 | return (ft_strcat(ft_utoa(duration / 3600), " hours ago.")); 92 | else if (duration < 172800) 93 | return ("1 day ago."); 94 | else if (duration < 2592000) 95 | return (ft_strcat(ft_utoa(duration / 86400), " days ago.")); 96 | else if (duration < 5184000) 97 | return ("1 month ago."); 98 | else 99 | return (ft_strcat(ft_utoa(duration / 2592000), " months ago.")); 100 | } 101 | -------------------------------------------------------------------------------- /3-0-add_prime_sum/add_prime_sum.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* add_prime_sum.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: lsauvage +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2018/01/08 14:16:28 by lsauvage #+# #+# */ 9 | /* Updated: 2018/01/08 17:27:47 by lsauvage ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | /* 21 | ** Write an integer on the standard output. 22 | ** Affiche un entier sur la sortie standard 23 | */ 24 | 25 | void ft_putnbr(int nb) 26 | { 27 | if (nb == -2147483648) 28 | { 29 | ft_putchar('-'); 30 | ft_putnbr(2); 31 | ft_putnbr(147483648); 32 | return ; 33 | } 34 | if (nb < 0) 35 | { 36 | ft_putchar('-'); 37 | nb = -nb; 38 | } 39 | if (nb >= 10) 40 | { 41 | ft_putnbr(nb / 10); 42 | ft_putnbr(nb % 10); 43 | } 44 | else 45 | ft_putchar(nb + '0'); 46 | } 47 | 48 | /* 49 | ** Convert a string to int. 50 | ** Conversion d'une chaine de caractere en entier. 51 | */ 52 | int ft_atoi(const char *str) 53 | { 54 | int i; 55 | int toi; 56 | int neg; 57 | 58 | i = 0; 59 | toi = 0; 60 | neg = 1; 61 | while (str[i] && (str[i] == ' ' || str[i] == '\t' || str[i] == '\n' 62 | || str[i] == '\v' || str[i] == '\r' || str[i] == '\f')) 63 | i++; 64 | if (str[i] == '+' || str[i] == '-') 65 | { 66 | if (str[i] == '-') 67 | neg = -neg; 68 | i++; 69 | } 70 | while (str[i] && (str[i] >= '0' && str[i] <= '9')) 71 | { 72 | toi = (toi * 10) + (str[i] - '0'); 73 | i++; 74 | } 75 | return (neg * toi); 76 | } 77 | 78 | /* 79 | ** Return 1 if nb is prime, 0 if not. 80 | ** Verifie si nb est premier ou non et retourne 1 ou 0. 81 | */ 82 | 83 | int ft_is_prime(int nb) 84 | { 85 | int i; 86 | 87 | i = 2; 88 | if (nb <= 1) 89 | return (0); 90 | while (i <= nb / i) 91 | { 92 | if (nb % i == 0) 93 | return (0); 94 | i++; 95 | } 96 | return (1); 97 | } 98 | 99 | /* 100 | ** Make the sum of all prime numbers inferior or equal to nb. 101 | ** Fait la somme de tous les entiers inferieurs ou egaux a nb. 102 | */ 103 | 104 | int add_prime_sum(int nb) 105 | { 106 | int res; 107 | 108 | res = 0; 109 | while (nb > 1) 110 | { 111 | if (ft_is_prime(nb)) 112 | res += nb; 113 | nb--; 114 | } 115 | return (res); 116 | } 117 | 118 | /* 119 | ** main function. 120 | */ 121 | 122 | int main(int ac, char **av) 123 | { 124 | if (ac == 2) 125 | ft_putnbr(add_prime_sum(ft_atoi(av[1]))); 126 | else 127 | ft_putnbr(0); 128 | ft_putchar('\n'); 129 | return (0); 130 | } 131 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **Exam shell** 2 | 3 | 42 (Paris) 4 | 5 | ### **Description** 6 | 7 | Liste des exercices réalisés lors des sessions d'exam à 42 8 | 9 | ![Level 0](images/level_0.png) 10 | 11 | | Subject | Status | 12 | |---------------------|---------------------| 13 | | **aff_a** | :x: | 14 | | **aff_first_param** | :white_check_mark: | 15 | | **ft_print_numbers**| :white_check_mark: | 16 | | **aff_last_param** | :white_check_mark: | 17 | | **aff_z** | :white_check_mark: | 18 | | **maff_alpha** | :white_check_mark: | 19 | | **maff_revalpha** | :white_check_mark: | 20 | | **only_z** | :white_check_mark: | 21 | | **strlen_sh** | :x: | 22 | | **ft_countdown** | :white_check_mark: | 23 | 24 | 25 | 26 | ![Level 1](images/level_1.png) 27 | 28 | | Subject | Status | 29 | |------------------------|---------------------| 30 | | **first_word** | :x: | 31 | | **ft_putstr** | :x: | 32 | | **ft_strcpy** | :x: :page_facing_up: | 33 | | **ft_strlen** | :x: | 34 | | **alpha_mirror** | :white_check_mark: | 35 | | **hello** | :x: | 36 | | **repeat_alpha** | :x: | 37 | | **rev_print** | :white_check_mark: | 38 | | **rot_13** | :x: | 39 | | **rotone** | :x: | 40 | | **search_and_replace** | :x: | 41 | | **ulstr** | :x: :page_facing_up: | 42 | 43 | ![Level 2](images/level_2.png) 44 | 45 | | Subject | Status | 46 | |--------------------|---------------------| 47 | | **ft_swap** | :white_check_mark: | 48 | | **do_op** | :white_check_mark: | 49 | | **ft_atoi** | :white_check_mark: | 50 | | **ft_strcmp** | :x: | 51 | | **ft_strdup** | :white_check_mark: | 52 | | **ft_strrev** | :white_check_mark: | 53 | | **inter** | :x: | 54 | | **last_word** | :x: | 55 | | **max** | :white_check_mark: | 56 | | **print_bits** | :x: | 57 | | **reverse_bits** | :white_check_mark: | 58 | | **swap_bits** | :white_check_mark: | 59 | | **union** | :white_check_mark: | 60 | | **wdmatch** | :x: | 61 | 62 | ![Level 3](images/level_3.png) 63 | 64 | | Subject | Status | 65 | |----------------------|---------------------| 66 | | **add_prime_sum** | :white_check_mark: | 67 | | **epur_str** | :x: | 68 | | **expand_str** | :x: | 69 | | **ft_atoi_base** | :white_check_mark: | 70 | | **lcm** | :white_check_mark: | 71 | | **ft_list_size** | :x: | 72 | | **ft_range** | :x: | 73 | | **ft_rrange** | :x: | 74 | | **hidenp** | :x: | 75 | | **paramsum** | :x: | 76 | | **pgcd** | :x: | 77 | | **print_hex** | :x: | 78 | | **rstr_capitalizer** | :white_check_mark: | 79 | | **str_capitalizer** | :white_check_mark: | 80 | | **tab_mult** | :x: | 81 | 82 | ![Level 4](images/level_4.png) 83 | 84 | | Subject | Status | 85 | |-----------------------|---------------------| 86 | | **fprime** | :white_check_mark: | 87 | | **ft_itoa** | :x::page_facing_up: | 88 | | **ft_list_foreach** | :page_facing_up: | 89 | | **ft_list_remove_if** | :white_check_mark: | 90 | | **ft_split** | :x::page_facing_up: | 91 | | **rev_wstr** | :x: | 92 | | **rostring** | :x::page_facing_up: | 93 | | **sort_int_tab** |:x: | 94 | | **sort_list** |:x: | 95 | 96 | ![Level 5](images/level_5.png) 97 | 98 | | Subject | Status | 99 | |--------------------|--------------------| 100 | | **brackets** | :x: | 101 | | **brainfuck** | :x: | 102 | | **ft_itoa_base** | :x::page_facing_up: | 103 | | **print_memory** | :x::page_facing_up: | 104 | | **rpn_calc** | :x::page_facing_up: | 105 | --------------------------------------------------------------------------------