├── shell00 ├── ex00 │ └── z ├── ex04 │ └── midLS ├── ex09 │ └── ft_magic ├── ex05 │ └── git_commit.sh ├── ex08 │ └── clean ├── ex06 │ └── git_ignore.sh ├── ex07 │ ├── .DS_Store │ └── b ├── ex03 │ └── id_rsa_pub ├── ex01 │ └── testShell00.tar └── ex02 │ └── exo2.tar ├── shell01 ├── ex05 │ └── _ │ │ └── _$_MaRViN_$_ │ │ └── _$_MaRViN_$_ ├── ex06 │ └── skip.sh ├── ex03 │ └── count_files.sh ├── ex04 │ └── MAC.sh ├── ex01 │ └── print_groups.sh └── ex02 │ └── find_sh.sh ├── medpool.jpg ├── C02 ├── ex02 │ ├── a.out │ └── ft_str_is_alpha.c ├── ex00 │ └── ft_strcpy.c ├── ex07 │ └── ft_strupcase.c ├── ex04 │ └── ft_str_is_lowercase.c ├── ex05 │ └── ft_str_is_uppercase.c ├── ex06 │ └── ft_str_is_printable.c ├── ex03 │ └── ft_str_is_numeric.c ├── ex01 │ └── ft_strncpy.c └── ex08 │ └── ft_strlowcase.c ├── C03 ├── ex00 │ ├── a.out │ └── ft_strcmp.c ├── ex04 │ ├── a.out │ └── ft_strstr.c ├── ex02 │ └── ft_strcat.c ├── ex01 │ └── ft_strncmp.c ├── ex03 │ └── ft_strncat.c └── ex05 │ └── ft_strstr.c ├── norminette.pdf ├── how_to_push_your_project.pdf ├── EXAM00 ├── 0-only_a │ ├── only_a.c │ └── subject.en.txt ├── 2-hello │ ├── hello.c │ └── subject.en.txt ├── 3-ft_swap │ ├── ft_swap.c │ └── subject.en.txt ├── 1-maff_alpha │ ├── maff_alpha.c │ └── subject.en.txt ├── 1-maff_revalpha │ ├── maff_revalpha.c │ └── subject.en.txt ├── 4-ft_strcmp │ ├── ft_strcmp.c │ └── subject.en.txt ├── 1-ft_print_numbers │ ├── ft_print_numbers.c │ └── subject.en.txt ├── 1-ft_countdown │ ├── ft_countdown.c │ └── subject.en.txt ├── exam00.txt ├── 4-ft_strrev │ ├── subject.en.txt │ └── ft_strrev.c └── 5-ft_atoi │ ├── subject.en.txt │ └── ft_atoi.c ├── EXAM01 ├── 0-only_z │ ├── only_z.c │ └── subject.en.txt ├── 1-ft_swap │ ├── ft_swap.c │ └── subject.en.txt ├── 1-ft_strlen │ ├── ft_strlen.c │ └── subject.en.txt ├── EXAM01.txt ├── 2-ft_strrev │ ├── subject.en.txt │ └── ft_strrev.c ├── 2-first_word │ ├── first_word.c │ └── subject.en.txt ├── 5-ft_itoa │ ├── subject.en.txt │ └── ft_itoa.c ├── 2-rotone │ ├── rotone.c │ └── subject.en.txt ├── 1-rev_print │ ├── revprint.c │ └── subject.en.txt ├── 2-rot_13 │ ├── rot13.c │ └── subject.en.txt ├── 3-last_word │ ├── last_word.c │ └── subject.en.txt ├── 5-ft_split │ ├── subject.en.txt │ └── ft_split.c ├── 3-inter │ ├── subject.en.txt │ └── inter.c ├── 4-ft_range │ ├── subject.en.txt │ └── ft_range.c ├── 3-wdmatch │ ├── wdmatch.c │ └── subject.en.txt └── 3-union │ ├── subject.en.txt │ └── union.c ├── EXAM02 ├── 1-ft_swap │ ├── ft_swap.c │ └── subject.en.txt ├── 1-ft_strlen │ ├── ft_strlen.c │ └── subject.en.txt ├── 0-aff_z │ ├── aff_z.c │ └── subject.en.txt ├── exam02.txt ├── 0-aff_a │ ├── aff_a.c │ └── subject.en.txt ├── 2-ft_strrev │ ├── subject.en.txt │ └── ft_strrev.c ├── 2-first_word │ ├── first_word.c │ └── subject.en.txt ├── 6-ft_itoa │ ├── subject.en.txt │ └── ft_itoa.c ├── 2-rotone │ ├── rotone.c │ └── subject.en.txt ├── 4-ft_atoi │ ├── subject.en.txt │ └── ft_atoi.c ├── 1-rev_print │ ├── revprint.c │ └── subject.en.txt ├── 2-rot_13 │ ├── rot13.c │ └── subject.en.txt ├── 3-last_word │ ├── last_word.c │ └── subject.en.txt ├── 6-ft_split │ ├── subject.en.txt │ └── ft_split.c ├── 3-inter │ ├── subject.en.txt │ └── inter.c ├── 5-ft_range │ ├── subject.en.txt │ └── ft_range.c ├── 3-wdmatch │ ├── wdmatch.c │ └── subject.en.txt └── 3-union │ ├── subject.en.txt │ └── union.c ├── EXAM03 ├── 0-aff_z │ ├── aff_z.c │ └── subject.en.txt ├── 1-ft_print_numbers │ ├── ft_print_numbers.c │ └── subject.en.txt ├── 5-ft_strcpy │ ├── ft_strcpy.c │ └── subject.en.txt ├── 4-aff_last_param │ ├── aff_last_param.c │ └── subject.en.txt ├── 7-ft_strrev │ ├── subject.en.txt │ └── ft_strrev.c ├── 6-ulstr │ ├── ulstr.c │ └── subject.en.txt ├── 12-sort_list │ ├── sort_list.c │ └── subject.en.txt ├── 8-ft_atoi │ ├── subject.en.txt │ └── ft_atoi.c ├── 3-rev_print │ ├── revprint.c │ └── subject.en.txt ├── EXAM.txt ├── 11-ft_split │ ├── subject.en.txt │ └── ft_split.c ├── 2-fizzbuzz │ ├── fizzbuzz.c │ └── subject.fr.txt ├── 10-ft_range │ ├── subject.en.txt │ └── ft_range.c ├── 9-union │ ├── subject.en.txt │ └── unionmomou.c ├── 13-count_alpha │ ├── subject.fr.txt │ └── count_alpha.c └── 14-str-maxlenoc │ ├── subject.fr.txt │ └── str_maxlenoc.c ├── C06 ├── ex03 │ └── ft_sort_params.c ├── ex00 │ └── ft_print_program_name.c ├── ex01 │ └── ft_print_params.c └── ex02 │ └── ft_rev_params.c ├── C00 ├── ex00 │ └── ft_putchar.c ├── ex01 │ └── ft_print_alphabet.c ├── ex04 │ └── ft_is_negative.c ├── ex03 │ └── ft_print_numbers.c ├── ex02 │ └── ft_print_reverse_alphabet.c ├── ex07 │ └── ft_putnbr.c ├── ex06 │ └── ft_print_comb2.c └── ex05 │ └── ft_print_comb.c ├── C04 ├── ex00 │ └── ft_strlen.c ├── ex01 │ └── ft_putstr.c ├── ex02 │ └── ft_putnbr.c └── ex03 │ └── ft_atoi.c ├── C01 ├── ex00 │ └── ft_ft.c ├── ex06 │ └── ft_strlen.c ├── ex02 │ └── ft_swap.c ├── ex03 │ └── ft_div_mod.c ├── ex05 │ └── ft_putstr.c ├── ex04 │ └── ft_ultimate_div_mod.c └── ex01 │ └── ft_ultimate_ft.c ├── C05 ├── ex06 │ └── ft_is_prime.c ├── ex05 │ └── ft_sqrt.c ├── ex04 │ └── ft_fibonacci.c ├── ex01 │ └── ft_recursive_factorial.c ├── ex00 │ └── ft_iterative_factorial.c ├── ex02 │ └── ft_iterative_power.c └── ex03 │ └── ft_recursive_power.c └── README.md /shell00/ex00/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /shell00/ex04/midLS: -------------------------------------------------------------------------------- 1 | ls -tpm 2 | -------------------------------------------------------------------------------- /shell01/ex05/_/_$_MaRViN_$_/_$_MaRViN_$_: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /shell00/ex09/ft_magic: -------------------------------------------------------------------------------- 1 | 41 string 42 42 file 2 | -------------------------------------------------------------------------------- /shell01/ex06/skip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l | awk 'NR%2==1' 3 | -------------------------------------------------------------------------------- /shell00/ex05/git_commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git log --format="%H" -n5 3 | -------------------------------------------------------------------------------- /shell01/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . | wc -l | sed 's/ //g' 3 | -------------------------------------------------------------------------------- /medpool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/medpool.jpg -------------------------------------------------------------------------------- /shell01/ex04/MAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ifconfig | grep -w ether | cut -d " " -f 2 3 | -------------------------------------------------------------------------------- /C02/ex02/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/C02/ex02/a.out -------------------------------------------------------------------------------- /C03/ex00/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/C03/ex00/a.out -------------------------------------------------------------------------------- /C03/ex04/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/C03/ex04/a.out -------------------------------------------------------------------------------- /norminette.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/norminette.pdf -------------------------------------------------------------------------------- /shell00/ex08/clean: -------------------------------------------------------------------------------- 1 | find . -type f \( -name "#*#" -o -name "*~" \) -print -delete 2 | -------------------------------------------------------------------------------- /shell01/ex01/print_groups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | id -Gn $FT_USER | tr ' ' ',' | tr -d "\n" 3 | -------------------------------------------------------------------------------- /shell00/ex06/git_ignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git ls-files --others --ignored --exclude-standard 3 | -------------------------------------------------------------------------------- /shell01/ex02/find_sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.sh" -exec basename {} .sh \; 3 | -------------------------------------------------------------------------------- /shell00/ex07/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/shell00/ex07/.DS_Store -------------------------------------------------------------------------------- /how_to_push_your_project.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AchrafMez/1337-piscine/HEAD/how_to_push_your_project.pdf -------------------------------------------------------------------------------- /EXAM00/0-only_a/only_a.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | write(1, "a", 1); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /EXAM01/0-only_z/only_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | write(1, "z", 1); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /EXAM00/2-hello/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | write(1, "Hello World!\n", 13); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /EXAM00/3-ft_swap/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int tmp; 4 | 5 | tmp = *a; 6 | *a = *b; 7 | *b = tmp; 8 | } 9 | -------------------------------------------------------------------------------- /EXAM01/1-ft_swap/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int tmp; 4 | 5 | tmp = *a; 6 | *a = *b; 7 | *b = tmp; 8 | } 9 | -------------------------------------------------------------------------------- /EXAM02/1-ft_swap/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int tmp; 4 | 5 | tmp = *a; 6 | *a = *b; 7 | *b = tmp; 8 | } 9 | -------------------------------------------------------------------------------- /EXAM00/1-maff_alpha/maff_alpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | write(1, "aBcDeFgHiJkLmNoPqRsTuVwXyZ\n", 27); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /EXAM01/1-ft_strlen/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i]) 7 | i++; 8 | return (i); 9 | } 10 | -------------------------------------------------------------------------------- /EXAM02/1-ft_strlen/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i]) 7 | i++; 8 | return (i); 9 | } 10 | -------------------------------------------------------------------------------- /EXAM00/1-maff_revalpha/maff_revalpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | write(1, "zYxWvUtSrQpOnMlKjIhGfEdCbA\n", 27); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /EXAM02/0-aff_z/aff_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | (void)ac; 6 | (void)av; 7 | write(1, "z\n", 2); 8 | return (0); 9 | } 10 | -------------------------------------------------------------------------------- /EXAM03/0-aff_z/aff_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | (void)ac; 6 | (void)av; 7 | write(1, "z\n", 2); 8 | return (0); 9 | } 10 | -------------------------------------------------------------------------------- /EXAM00/4-ft_strcmp/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | int ft_strcmp(char *s1, char *s2) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i]) 7 | i++; 8 | return (s1[i] - s2[i]); 9 | } 10 | -------------------------------------------------------------------------------- /EXAM00/1-ft_print_numbers/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_print_numbers(void) 4 | { 5 | char digit; 6 | 7 | digit = '0'; 8 | while (digit <= '9') 9 | { 10 | write(1, &digit, 1); 11 | digit++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /EXAM03/1-ft_print_numbers/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_print_numbers(void) 4 | { 5 | char digit; 6 | 7 | digit = '0'; 8 | while (digit <= '9') 9 | { 10 | write(1, &digit, 1); 11 | digit++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /EXAM03/5-ft_strcpy/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *ft_strcpy(char *s1, char *s2) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (s2[i] != '\0') 9 | { 10 | s1[i] = s2[i]; 11 | i++; 12 | } 13 | s1[i] = '\0'; 14 | return (s1); 15 | } 16 | -------------------------------------------------------------------------------- /EXAM00/1-ft_countdown/ft_countdown.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | char digit; 6 | 7 | digit = '9'; 8 | while (digit >= '0') 9 | { 10 | write(1, &digit, 1); 11 | digit--; 12 | } 13 | write(1, "\n", 1); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /EXAM00/0-only_a/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : only_a 2 | Expected files : only_a.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays a 'a' character on the standard output. 7 | -------------------------------------------------------------------------------- /EXAM01/0-only_z/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : only_z 2 | Expected files : only_z.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays a 'z' character on the standard output. 7 | -------------------------------------------------------------------------------- /EXAM00/exam00.txt: -------------------------------------------------------------------------------- 1 | Exam 00: 6 exercices 2 | 0-only_a 16points 3 | 1-maff_revelalpha or 1-ft_countdown or 1-ft_print_numbers or 1-maff_alpha 16points -> 32/100 4 | 2-hello 16points -> 48/100 5 | 3-ft_swap 16points -> 64/100 6 | 4- ft_strcmp or ft_strrev 16points -> 80/100 7 | 5-ft_atoi 20points -> 100/100 -------------------------------------------------------------------------------- /EXAM03/4-aff_last_param/aff_last_param.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | if (ac > 1) 9 | { 10 | ac--; 11 | while (av[ac][i] != '\0') 12 | { 13 | write(1, &av[ac][i], 1); 14 | i++; 15 | } 16 | } 17 | write(1, "\n", 1); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /EXAM01/EXAM01.txt: -------------------------------------------------------------------------------- 1 | exam01 6 exercices 2 | 0-only z 16points 3 | 1-rev_print or 1-ft_strlen or 1-ft_swap 16points -> 32/100 4 | 2-rot_13 or 2-rotone or 2-first_word or 2-ft_strrev 16points -> 48/100 5 | 3-inter or 3-last_word or 3-union or 3-wdmatch 16points -> 64/100 6 | 4-ft_range 16points -> 16 points -> 80/100 7 | 5-ft_itoa or ft_split -> 20 points -> 100/100 -------------------------------------------------------------------------------- /EXAM01/1-ft_strlen/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strlen 2 | Expected files : ft_strlen.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that returns the length of a string. 7 | 8 | Your function must be declared as follows: 9 | 10 | int ft_strlen(char *str); 11 | -------------------------------------------------------------------------------- /EXAM02/1-ft_strlen/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strlen 2 | Expected files : ft_strlen.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that returns the length of a string. 7 | 8 | Your function must be declared as follows: 9 | 10 | int ft_strlen(char *str); 11 | -------------------------------------------------------------------------------- /EXAM00/2-hello/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : hello 2 | Expected files : hello.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays "Hello World!" followed by a \n. 7 | 8 | Example: 9 | 10 | $>./hello 11 | Hello World! 12 | $>./hello | cat -e 13 | Hello World!$ 14 | $> 15 | -------------------------------------------------------------------------------- /EXAM00/4-ft_strcmp/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strcmp 2 | Expected files : ft_strcmp.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Reproduce the behavior of the function strcmp (man strcmp). 7 | 8 | Your function must be declared as follows: 9 | 10 | int ft_strcmp(char *s1, char *s2); 11 | -------------------------------------------------------------------------------- /EXAM02/exam02.txt: -------------------------------------------------------------------------------- 1 | exam02 7 exercices 2 | 0-aff_a or 0-aff_z 14points 3 | 1-rev_print or 1-ft_swap or 1-ft-strlen 14points -> 28/100 4 | 2-first_word or 2-ft_strrev or 2-rot_13 or 2-rotone 14points -> 42/100 5 | 3-inter or 3-last_word or 3-union or 3-wdmatch 14points -> 56/100 6 | 4-ft_atoi 14points -> 70/100 7 | 5-ft_range 14points -> 84/100 8 | 6-ft_itoa or 6-ft_split 16points -> 100/100 -------------------------------------------------------------------------------- /EXAM03/5-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 | -------------------------------------------------------------------------------- /EXAM00/1-ft_countdown/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_countdown 2 | Expected files : ft_countdown.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays all digits in descending order, followed by a 7 | newline. 8 | 9 | Example: 10 | $> ./ft_countdown | cat -e 11 | 9876543210$ 12 | $> 13 | -------------------------------------------------------------------------------- /EXAM00/1-ft_print_numbers/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_print_numbers 2 | Expected files : ft_print_numbers.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that displays all digits in ascending order. 7 | 8 | Your function must be declared as follows: 9 | 10 | void ft_print_numbers(void); 11 | -------------------------------------------------------------------------------- /EXAM03/1-ft_print_numbers/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_print_numbers 2 | Expected files : ft_print_numbers.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that displays all digits in ascending order. 7 | 8 | Your function must be declared as follows: 9 | 10 | void ft_print_numbers(void); 11 | -------------------------------------------------------------------------------- /EXAM02/0-aff_a/aff_a.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | if (ac == 2) 9 | { 10 | while (av[1][i] != '\0') 11 | { 12 | if (av[1][i] == 'a') 13 | { 14 | write(1, "a", 1); 15 | break ; 16 | } 17 | i++; 18 | } 19 | write(1, "\n", 1); 20 | } 21 | else 22 | write(1, "a\n", 2); 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /EXAM00/4-ft_strrev/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strrev 2 | Expected files : ft_strrev.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that reverses (in-place) a string. 7 | 8 | It must return its parameter. 9 | 10 | Your function must be declared as follows: 11 | 12 | char *ft_strrev(char *str); 13 | -------------------------------------------------------------------------------- /EXAM01/2-ft_strrev/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strrev 2 | Expected files : ft_strrev.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that reverses (in-place) a string. 7 | 8 | It must return its parameter. 9 | 10 | Your function must be declared as follows: 11 | 12 | char *ft_strrev(char *str); 13 | -------------------------------------------------------------------------------- /EXAM02/2-ft_strrev/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strrev 2 | Expected files : ft_strrev.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that reverses (in-place) a string. 7 | 8 | It must return its parameter. 9 | 10 | Your function must be declared as follows: 11 | 12 | char *ft_strrev(char *str); 13 | -------------------------------------------------------------------------------- /EXAM03/7-ft_strrev/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_strrev 2 | Expected files : ft_strrev.c 3 | Allowed functions: 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that reverses (in-place) a string. 7 | 8 | It must return its parameter. 9 | 10 | Your function must be declared as follows: 11 | 12 | char *ft_strrev(char *str); 13 | -------------------------------------------------------------------------------- /EXAM01/2-first_word/first_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | if (ac == 2) 9 | { 10 | while (av[1][i] == ' ' || av[1][i] == '\t') 11 | i++; 12 | while (av[1][i] != '\0' && av[1][i] != ' ' && av[1][i] != '\t') 13 | { 14 | write(1, &av[1][i], 1); 15 | i++; 16 | } 17 | } 18 | write(1, "\n", 1); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /EXAM02/2-first_word/first_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | if (ac == 2) 9 | { 10 | while (av[1][i] == ' ' || av[1][i] == '\t') 11 | i++; 12 | while (av[1][i] != '\0' && av[1][i] != ' ' && av[1][i] != '\t') 13 | { 14 | write(1, &av[1][i], 1); 15 | i++; 16 | } 17 | } 18 | write(1, "\n", 1); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /EXAM00/3-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 | -------------------------------------------------------------------------------- /EXAM01/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 | -------------------------------------------------------------------------------- /EXAM02/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 | -------------------------------------------------------------------------------- /EXAM00/1-maff_alpha/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : maff_alpha 2 | Expected files : maff_alpha.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays the alphabet, with even letters in uppercase, and 7 | odd letters in lowercase, followed by a newline. 8 | 9 | Example: 10 | 11 | $> ./maff_alpha | cat -e 12 | aBcDeFgHiJkLmNoPqRsTuVwXyZ$ 13 | -------------------------------------------------------------------------------- /EXAM03/6-ulstr/ulstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int ac, char **av) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | if (ac == 2) 9 | { 10 | while (av[1][i] != '\0') 11 | { 12 | if (av[1][i] >= 'A' && av[1][i] <= 'Z') 13 | av[1][i] += 32; 14 | else if (av[1][i] >= 'a' && av[1][i] <= 'z') 15 | av[1][i] -= 32; 16 | write(1, &av[1][i], 1); 17 | i++; 18 | } 19 | } 20 | write(1, "\n", 1); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /EXAM00/4-ft_strrev/ft_strrev.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | i++; 8 | return (i); 9 | } 10 | 11 | char *ft_strrev(char *str) 12 | { 13 | int i; 14 | int len; 15 | char tmp; 16 | 17 | i = 0; 18 | len = ft_strlen(str) - 1; 19 | while (len > i) 20 | { 21 | tmp = str[i]; 22 | str[i] = str[len]; 23 | str[len] = tmp; 24 | i++; 25 | len--; 26 | } 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /EXAM01/2-ft_strrev/ft_strrev.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | i++; 8 | return (i); 9 | } 10 | 11 | char *ft_strrev(char *str) 12 | { 13 | int i; 14 | int len; 15 | char tmp; 16 | 17 | i = 0; 18 | len = ft_strlen(str) - 1; 19 | while (len > i) 20 | { 21 | tmp = str[i]; 22 | str[i] = str[len]; 23 | str[len] = tmp; 24 | i++; 25 | len--; 26 | } 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /EXAM02/2-ft_strrev/ft_strrev.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | i++; 8 | return (i); 9 | } 10 | 11 | char *ft_strrev(char *str) 12 | { 13 | int i; 14 | int len; 15 | char tmp; 16 | 17 | i = 0; 18 | len = ft_strlen(str) - 1; 19 | while (len > i) 20 | { 21 | tmp = str[i]; 22 | str[i] = str[len]; 23 | str[len] = tmp; 24 | i++; 25 | len--; 26 | } 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /EXAM03/7-ft_strrev/ft_strrev.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | i++; 8 | return (i); 9 | } 10 | 11 | char *ft_strrev(char *str) 12 | { 13 | int i; 14 | int len; 15 | char tmp; 16 | 17 | i = 0; 18 | len = ft_strlen(str) - 1; 19 | while (len > i) 20 | { 21 | tmp = str[i]; 22 | str[i] = str[len]; 23 | str[len] = tmp; 24 | i++; 25 | len--; 26 | } 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /EXAM01/5-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 | -------------------------------------------------------------------------------- /EXAM02/6-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 | -------------------------------------------------------------------------------- /EXAM00/1-maff_revalpha/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : maff_revalpha 2 | Expected files : maff_revalpha.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that displays the alphabet in reverse, with even letters in 7 | uppercase, and odd letters in lowercase, followed by a newline. 8 | 9 | Example: 10 | 11 | $> ./maff_revalpha | cat -e 12 | zYxWvUtSrQpOnMlKjIhGfEdCbA$ 13 | -------------------------------------------------------------------------------- /EXAM01/2-rotone/rotone.c: -------------------------------------------------------------------------------- 1 | #include 2 | void rotone(char * str) 3 | { 4 | int i; 5 | i = 0; 6 | while(str[i] != '\0') 7 | { 8 | if ( (str[i] >= 'A' && str[i] <= 'Y') || (str[i] >= 'a' && str[i] <= 'y')) 9 | str[i] += 1; 10 | else if (str[i] == 'Z' || str[i] == 'z') 11 | str[i] -= 25; 12 | write (1, &str[i], 1); 13 | i++; 14 | } 15 | } 16 | 17 | int main(int ac, char **av) 18 | { 19 | if (ac == 2) 20 | rotone(av[1]); 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /EXAM02/2-rotone/rotone.c: -------------------------------------------------------------------------------- 1 | #include 2 | void rotone(char * str) 3 | { 4 | int i; 5 | i = 0; 6 | while(str[i] != '\0') 7 | { 8 | if ( (str[i] >= 'A' && str[i] <= 'Y') || (str[i] >= 'a' && str[i] <= 'y')) 9 | str[i] += 1; 10 | else if (str[i] == 'Z' || str[i] == 'z') 11 | str[i] -= 25; 12 | write (1, &str[i], 1); 13 | i++; 14 | } 15 | } 16 | 17 | int main(int ac, char **av) 18 | { 19 | if (ac == 2) 20 | rotone(av[1]); 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /EXAM03/12-sort_list/sort_list.c: -------------------------------------------------------------------------------- 1 | #include "list.h" 2 | 3 | t_list *sort_list(t_list* lst, int (*cmp)(int, int)) 4 | { 5 | int swap; 6 | t_list *tmp; 7 | 8 | tmp = lst; 9 | while (lst->next != 0) 10 | { 11 | if (((*cmp)(lst->data, lst->next->data)) == 0) 12 | { 13 | swap = lst->data; 14 | lst->data = lst->next->data; 15 | lst->next->data = swap; 16 | lst = tmp; 17 | } 18 | else 19 | lst = lst->next; 20 | } 21 | lst = tmp; 22 | return (lst); 23 | } 24 | -------------------------------------------------------------------------------- /EXAM00/5-ft_atoi/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_atoi 2 | Expected files : ft_atoi.c 3 | Allowed functions: None 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that converts the string argument str to an integer (type int) 7 | and returns it. 8 | 9 | It works much like the standard atoi(const char *str) function, see the man. 10 | 11 | Your function must be declared as follows: 12 | 13 | int ft_atoi(const char *str); 14 | -------------------------------------------------------------------------------- /EXAM02/4-ft_atoi/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_atoi 2 | Expected files : ft_atoi.c 3 | Allowed functions: None 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that converts the string argument str to an integer (type int) 7 | and returns it. 8 | 9 | It works much like the standard atoi(const char *str) function, see the man. 10 | 11 | Your function must be declared as follows: 12 | 13 | int ft_atoi(const char *str); 14 | -------------------------------------------------------------------------------- /EXAM03/8-ft_atoi/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_atoi 2 | Expected files : ft_atoi.c 3 | Allowed functions: None 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that converts the string argument str to an integer (type int) 7 | and returns it. 8 | 9 | It works much like the standard atoi(const char *str) function, see the man. 10 | 11 | Your function must be declared as follows: 12 | 13 | int ft_atoi(const char *str); 14 | -------------------------------------------------------------------------------- /EXAM01/1-rev_print/revprint.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_strlen(char *str) 4 | { 5 | int i; 6 | i = 0; 7 | while(str[i] != '\0') 8 | i++; 9 | return (i); 10 | } 11 | char *ft_rev_print(char *str) 12 | { 13 | int i; 14 | 15 | i = ft_strlen(str); 16 | i--; 17 | while (i >= 0) 18 | { 19 | write(1, &str[i], 1); 20 | i--; 21 | } 22 | return(str); 23 | } 24 | 25 | int main() 26 | { 27 | char str[] = "gbrireugneb"; 28 | ft_rev_print(str); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /EXAM02/1-rev_print/revprint.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_strlen(char *str) 4 | { 5 | int i; 6 | i = 0; 7 | while(str[i] != '\0') 8 | i++; 9 | return (i); 10 | } 11 | char *ft_rev_print(char *str) 12 | { 13 | int i; 14 | 15 | i = ft_strlen(str); 16 | i--; 17 | while (i >= 0) 18 | { 19 | write(1, &str[i], 1); 20 | i--; 21 | } 22 | return(str); 23 | } 24 | 25 | int main() 26 | { 27 | char str[] = "gbrireugneb"; 28 | ft_rev_print(str); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /EXAM03/3-rev_print/revprint.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_strlen(char *str) 4 | { 5 | int i; 6 | i = 0; 7 | while(str[i] != '\0') 8 | i++; 9 | return (i); 10 | } 11 | char *ft_rev_print(char *str) 12 | { 13 | int i; 14 | 15 | i = ft_strlen(str); 16 | i--; 17 | while (i >= 0) 18 | { 19 | write(1, &str[i], 1); 20 | i--; 21 | } 22 | return(str); 23 | } 24 | 25 | int main() 26 | { 27 | char str[] = "gbrireugneb"; 28 | ft_rev_print(str); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /EXAM01/2-rot_13/rot13.c: -------------------------------------------------------------------------------- 1 | #include 2 | void rot13(char *str) 3 | { 4 | int i; 5 | i = 0; 6 | while( str[i] != '\0') 7 | { 8 | if( (str[i] >= 'A' && str[i] <= 'M') || (str[i] >= 'a' && str[i] <= 'm') ) 9 | str[i] += 13; 10 | else if( (str[i] >= 'N' && str[i] <= 'Z') || (str[i] >= 'n' && str[i] <= 'z') ) 11 | str[i] -= 13; 12 | write(1, &str[i], 1); 13 | i++; 14 | } 15 | } 16 | 17 | int main(int ac, char **av) 18 | { 19 | if (ac == 2) 20 | rot13(av[1]); 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /EXAM02/2-rot_13/rot13.c: -------------------------------------------------------------------------------- 1 | #include 2 | void rot13(char *str) 3 | { 4 | int i; 5 | i = 0; 6 | while( str[i] != '\0') 7 | { 8 | if( (str[i] >= 'A' && str[i] <= 'M') || (str[i] >= 'a' && str[i] <= 'm') ) 9 | str[i] += 13; 10 | else if( (str[i] >= 'N' && str[i] <= 'Z') || (str[i] >= 'n' && str[i] <= 'z') ) 11 | str[i] -= 13; 12 | write(1, &str[i], 1); 13 | i++; 14 | } 15 | } 16 | 17 | int main(int ac, char **av) 18 | { 19 | if (ac == 2) 20 | rot13(av[1]); 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /EXAM00/5-ft_atoi/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(const char *str) 2 | { 3 | int i; 4 | int sign; 5 | int result; 6 | 7 | i = 0; 8 | sign = 1; 9 | result = 0; 10 | while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13)) 11 | i++; 12 | if (str[i] == '-') 13 | { 14 | sign = -1; 15 | i++; 16 | } 17 | else if (str[i] == '+') 18 | i++; 19 | while (str[i] != '\0' && str[i] >= '0' && str[i] <= '9') 20 | { 21 | result *= 10; 22 | result += str[i] - '0'; 23 | i++; 24 | } 25 | return (result * sign); 26 | } 27 | -------------------------------------------------------------------------------- /EXAM02/4-ft_atoi/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(const char *str) 2 | { 3 | int i; 4 | int sign; 5 | int result; 6 | 7 | i = 0; 8 | sign = 1; 9 | result = 0; 10 | while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13)) 11 | i++; 12 | if (str[i] == '-') 13 | { 14 | sign = -1; 15 | i++; 16 | } 17 | else if (str[i] == '+') 18 | i++; 19 | while (str[i] != '\0' && str[i] >= '0' && str[i] <= '9') 20 | { 21 | result *= 10; 22 | result += str[i] - '0'; 23 | i++; 24 | } 25 | return (result * sign); 26 | } 27 | -------------------------------------------------------------------------------- /EXAM03/8-ft_atoi/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(const char *str) 2 | { 3 | int i; 4 | int sign; 5 | int result; 6 | 7 | i = 0; 8 | sign = 1; 9 | result = 0; 10 | while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13)) 11 | i++; 12 | if (str[i] == '-') 13 | { 14 | sign = -1; 15 | i++; 16 | } 17 | else if (str[i] == '+') 18 | i++; 19 | while (str[i] != '\0' && str[i] >= '0' && str[i] <= '9') 20 | { 21 | result *= 10; 22 | result += str[i] - '0'; 23 | i++; 24 | } 25 | return (result * sign); 26 | } 27 | -------------------------------------------------------------------------------- /EXAM03/EXAM.txt: -------------------------------------------------------------------------------- 1 | exam03 16exercices (6points pour chaque exercice, 10 points pour le dernier exercice) 2 | _____________________________ 3 | 0-aff_z 4 | 1-ft_print_numbers 5 | ____________________ 6 | 2-fizzbuzz 7 | 3-rev_print 8 | 4-aff_last_param 9 | 5-ulstr 10 | 6-ft_strcpy 11 | _____________________ 12 | 7-ft_strrev 13 | 8-ft_atoi 14 | 9-union 15 | _________________ 16 | 10- ft_range 17 | _________________ 18 | 11-ft_split 19 | 12-sort_list 20 | 13-count_alpha 21 | _________________ 22 | 14-str_maxlenoc 23 | 15-count_island -------------------------------------------------------------------------------- /EXAM01/3-last_word/last_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | void last_word(char *str) 3 | { 4 | int i = 0; 5 | while (str[i] != '\0') 6 | i++; 7 | i -= 1; 8 | while(str[i] == '\t' || str[i] == 32) 9 | i--; 10 | while (i > 0) 11 | { if(str[i] == 32 && str[i] == '\t') 12 | break; 13 | i--; 14 | } 15 | i++; 16 | while (str[i] != '\0' && str[i] != 32 && str[i] != '\t') 17 | { 18 | write(1, &str[i], 1); 19 | i++; 20 | } 21 | } 22 | int main(int ac, char **av) 23 | { 24 | if (ac == 2) 25 | last_word(av[1]); 26 | write(1, "\n", 1); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /EXAM01/5-ft_split/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_split 2 | Expected files : ft_split.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string, splits it into words, and returns them as 7 | a NULL-terminated array of strings. 8 | 9 | A "word" is defined as a part of a string delimited either by spaces/tabs/new 10 | lines, or by the start/end of the string. 11 | 12 | Your function must be declared as follows: 13 | 14 | char **ft_split(char *str); 15 | -------------------------------------------------------------------------------- /EXAM02/3-last_word/last_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | void last_word(char *str) 3 | { 4 | int i = 0; 5 | while (str[i] != '\0') 6 | i++; 7 | i -= 1; 8 | while(str[i] == '\t' || str[i] == 32) 9 | i--; 10 | while (i > 0) 11 | { if(str[i] == 32 || str[i] == '\t') 12 | break; 13 | i--; 14 | } 15 | i++; 16 | while (str[i] != '\0' && str[i] != 32 && str[i] != '\t') 17 | { 18 | write(1, &str[i], 1); 19 | i++; 20 | } 21 | } 22 | int main(int ac, char **av) 23 | { 24 | if (ac == 2) 25 | last_word(av[1]); 26 | write(1, "\n", 1); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /EXAM02/6-ft_split/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_split 2 | Expected files : ft_split.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string, splits it into words, and returns them as 7 | a NULL-terminated array of strings. 8 | 9 | A "word" is defined as a part of a string delimited either by spaces/tabs/new 10 | lines, or by the start/end of the string. 11 | 12 | Your function must be declared as follows: 13 | 14 | char **ft_split(char *str); 15 | -------------------------------------------------------------------------------- /EXAM03/11-ft_split/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_split 2 | Expected files : ft_split.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string, splits it into words, and returns them as 7 | a NULL-terminated array of strings. 8 | 9 | A "word" is defined as a part of a string delimited either by spaces/tabs/new 10 | lines, or by the start/end of the string. 11 | 12 | Your function must be declared as follows: 13 | 14 | char **ft_split(char *str); 15 | -------------------------------------------------------------------------------- /shell00/ex03/id_rsa_pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCq1MKHZ1LU2K676McQxY0FhgpPw8N25K956mBle6XJPI14lFBdOOPuBa2mhhKMHFAgsJcLj1sL8mwJcqrtMl+rXnfvexriZLUenJkiNxkti9zDV+zE3AS9V6GpwbQhI30XhZhP5lVTnLeVQDOiVz0kwe+Tz1emetKdhrlofYQdFWp9SrlvM68J2cWdJGLQSq7KMkCIZvoVu4uikyMZ2H9ymdWvPgmjJjVzH/IV2+poJsJsVNwPAcvKbVU21IzoJz/U4Gb7kNHJ/o54uJ0V06L1AhkOYkALI7FRPYUHeQ8Iz039ysDqvodOBFNQmdVluDq/PIZtpPsibAmoxvXHs/jFLhAtazA6OT0lmhfX0uwX+MFnH+LxwaVA9Iurehn/mX8YXxlmPTLIsVycaT2yjQAoBesod1QAYzFPdx9j7BFq7EY54OL17wRfv4MSSeyVA6hZas6dAovGq8+EmfzRJTJjwcFRZ2xkQI6GoyihUKrZ3M+yQPa/rArd1Y2JSEg1TDU= amezioun@c2r5p5.1337.ma 2 | -------------------------------------------------------------------------------- /shell00/ex07/b: -------------------------------------------------------------------------------- 1 | Episode V, A NEW H0PE It is a period of civil war 2 | Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. 3 | During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the STAR DEATH, an armored space station with enough power to destroy an entire planet. 4 | 5 | 6 | Pursued by the Empire's sinister agents, 7 | Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie.. 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /EXAM01/1-rev_print/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_print 2 | Expected files : rev_print.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string and displays the string in reverse 7 | order followed by the newline. 8 | Its prototype is constructed like this : 9 | char *ft_rev_print (char *str) 10 | It must return its argument 11 | 12 | Examples: 13 | 14 | $> ./rev_print "zaz" | cat -e 15 | zaz$ 16 | $> ./rev_print "dub0 a POIL" | cat -e 17 | LIOP a 0bud$ 18 | $> ./rev_print | cat -e 19 | $ 20 | -------------------------------------------------------------------------------- /EXAM02/1-rev_print/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_print 2 | Expected files : rev_print.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string and displays the string in reverse 7 | order followed by the newline. 8 | Its prototype is constructed like this : 9 | char *ft_rev_print (char *str) 10 | It must return its argument 11 | 12 | Examples: 13 | 14 | $> ./rev_print "zaz" | cat -e 15 | zaz$ 16 | $> ./rev_print "dub0 a POIL" | cat -e 17 | LIOP a 0bud$ 18 | $> ./rev_print | cat -e 19 | $ 20 | -------------------------------------------------------------------------------- /EXAM03/3-rev_print/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rev_print 2 | Expected files : rev_print.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a function that takes a string and displays the string in reverse 7 | order followed by the newline. 8 | Its prototype is constructed like this : 9 | char *ft_rev_print (char *str) 10 | It must return its argument 11 | 12 | Examples: 13 | 14 | $> ./rev_print "zaz" | cat -e 15 | zaz$ 16 | $> ./rev_print "dub0 a POIL" | cat -e 17 | LIOP a 0bud$ 18 | $> ./rev_print | cat -e 19 | $ 20 | -------------------------------------------------------------------------------- /EXAM03/2-fizzbuzz/fizzbuzz.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_write_number(int number) 4 | { 5 | if (number > 9) 6 | ft_write_number(number / 10); 7 | write(1, &"0123456789"[number % 10], 1); 8 | } 9 | 10 | int main(void) 11 | { 12 | int number; 13 | 14 | number = 1; 15 | while (number <= 100) 16 | { 17 | if (number % 3 == 0 && number % 5 == 0) 18 | write(1, "fizzbuzz", 8); 19 | else if (number % 3 == 0) 20 | write(1, "fizz", 4); 21 | else if (number % 5 == 0) 22 | write(1, "buzz", 4); 23 | else 24 | ft_write_number(number); 25 | write(1, "\n", 1); 26 | number++; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /EXAM03/4-aff_last_param/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment 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 | -------------------------------------------------------------------------------- /EXAM02/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 | -------------------------------------------------------------------------------- /EXAM02/0-aff_z/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_z 2 | Expected files : aff_z.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string, and displays the first 'z' 7 | character it encounters in it, followed by a newline. If there are no 8 | 'z' characters in the string, the program writes 'z' followed 9 | by a newline. If the number of parameters is not 1, the program displays 10 | 'z' followed by a newline. 11 | 12 | Example: 13 | 14 | $> ./aff_z "abc" | cat -e 15 | z$ 16 | $> ./aff_z "dubO a POIL" | cat -e 17 | z$ 18 | $> ./aff_z "zaz sent le poney" | cat -e 19 | z$ 20 | $> ./aff_z | cat -e 21 | z$ 22 | -------------------------------------------------------------------------------- /EXAM03/0-aff_z/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : aff_z 2 | Expected files : aff_z.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string, and displays the first 'z' 7 | character it encounters in it, followed by a newline. If there are no 8 | 'z' characters in the string, the program writes 'z' followed 9 | by a newline. If the number of parameters is not 1, the program displays 10 | 'z' followed by a newline. 11 | 12 | Example: 13 | 14 | $> ./aff_z "abc" | cat -e 15 | z$ 16 | $> ./aff_z "dubO a POIL" | cat -e 17 | z$ 18 | $> ./aff_z "zaz sent le poney" | cat -e 19 | z$ 20 | $> ./aff_z | cat -e 21 | z$ 22 | -------------------------------------------------------------------------------- /EXAM01/3-inter/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : inter 2 | Expected files : inter.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and displays, without doubles, the 7 | characters that appear in both strings, in the order they appear in the first 8 | one. 9 | 10 | The display will be followed by a \n. 11 | 12 | If the number of arguments is not 2, the program displays \n. 13 | 14 | Examples: 15 | 16 | $>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 17 | padinto$ 18 | $>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 19 | df6ewg4$ 20 | $>./inter "rien" "cette phrase ne cache rien" | cat -e 21 | rien$ 22 | $>./inter | cat -e 23 | $ 24 | -------------------------------------------------------------------------------- /EXAM02/3-inter/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : inter 2 | Expected files : inter.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and displays, without doubles, the 7 | characters that appear in both strings, in the order they appear in the first 8 | one. 9 | 10 | The display will be followed by a \n. 11 | 12 | If the number of arguments is not 2, the program displays \n. 13 | 14 | Examples: 15 | 16 | $>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 17 | padinto$ 18 | $>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 19 | df6ewg4$ 20 | $>./inter "rien" "cette phrase ne cache rien" | cat -e 21 | rien$ 22 | $>./inter | cat -e 23 | $ 24 | -------------------------------------------------------------------------------- /EXAM01/3-inter/inter.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_doubles(char *str, char c, int pos) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (i < pos) 9 | { 10 | if (str[i] == c) 11 | return (0); 12 | i++; 13 | } 14 | return (1); 15 | } 16 | void inter(char *str, char *str1) 17 | { 18 | int i; 19 | int j; 20 | 21 | i = 0; 22 | while (str[i] != '\0') 23 | { 24 | j = 0; 25 | while (str1[j] != '\0') 26 | { 27 | if (str[i] == str1[j]) 28 | { 29 | if (check_doubles(str, str[i], i) == 1) 30 | { 31 | write(1, &str[i], 1); 32 | break; 33 | } 34 | } 35 | j++; 36 | } 37 | i++; 38 | } 39 | } 40 | int main(int ac, char **av) 41 | { 42 | 43 | if (ac == 3) 44 | inter(av[1], av[2]); 45 | write(1, "\n", 1); 46 | return (0); 47 | } 48 | -------------------------------------------------------------------------------- /EXAM02/3-inter/inter.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_doubles(char *str, char c, int pos) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (i < pos) 9 | { 10 | if (str[i] == c) 11 | return (0); 12 | i++; 13 | } 14 | return (1); 15 | } 16 | void inter(char *str, char *str1) 17 | { 18 | int i; 19 | int j; 20 | 21 | i = 0; 22 | while (str[i] != '\0') 23 | { 24 | j = 0; 25 | while (str1[j] != '\0') 26 | { 27 | if (str[i] == str1[j]) 28 | { 29 | if (check_doubles(str, str[i], i) == 1) 30 | { 31 | write(1, &str[i], 1); 32 | break; 33 | } 34 | } 35 | j++; 36 | } 37 | i++; 38 | } 39 | } 40 | int main(int ac, char **av) 41 | { 42 | 43 | if (ac == 3) 44 | inter(av[1], av[2]); 45 | write(1, "\n", 1); 46 | return (0); 47 | } 48 | -------------------------------------------------------------------------------- /EXAM01/5-ft_itoa/ft_itoa.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int len(long nb) 5 | { 6 | int len = 0; 7 | if (nb < 0) 8 | { 9 | nb *= -1; 10 | len++; 11 | } 12 | while (nb > 0) 13 | { 14 | nb /= 10; 15 | len++; 16 | } 17 | return(len); 18 | } 19 | char *ft_itoa(int nb) 20 | { 21 | char *str; 22 | long n; 23 | int i; 24 | 25 | n = nb; 26 | i = len(n); 27 | if(!(str = (char *)malloc(i + 1))) 28 | return(0); 29 | str[i--] = '\0'; 30 | if (n == 0) 31 | { 32 | str[0] = 48; 33 | return(str); 34 | } 35 | if(n < 0) 36 | { 37 | str[0] = '-'; 38 | n *= -1; 39 | } 40 | while (n > 0) 41 | { 42 | str[i] = 48 + (n % 10); 43 | n /= 10; 44 | i--; 45 | } 46 | return (str); 47 | } 48 | 49 | int main(void) 50 | { 51 | printf("%s\n", ft_itoa(1342345)); 52 | } 53 | -------------------------------------------------------------------------------- /EXAM02/6-ft_itoa/ft_itoa.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int len(long nb) 5 | { 6 | int len = 0; 7 | if (nb < 0) 8 | { 9 | nb *= -1; 10 | len++; 11 | } 12 | while (nb > 0) 13 | { 14 | nb /= 10; 15 | len++; 16 | } 17 | return(len); 18 | } 19 | char *ft_itoa(int nb) 20 | { 21 | char *str; 22 | long n; 23 | int i; 24 | 25 | n = nb; 26 | i = len(n); 27 | if(!(str = (char *)malloc(i + 1))) 28 | return(0); 29 | str[i--] = '\0'; 30 | if (n == 0) 31 | { 32 | str[0] = 48; 33 | return(str); 34 | } 35 | if(n < 0) 36 | { 37 | str[0] = '-'; 38 | n *= -1; 39 | } 40 | while (n > 0) 41 | { 42 | str[i] = 48 + (n % 10); 43 | n /= 10; 44 | i--; 45 | } 46 | return (str); 47 | } 48 | 49 | int main(void) 50 | { 51 | printf("%s\n", ft_itoa(1342345)); 52 | } 53 | -------------------------------------------------------------------------------- /EXAM01/4-ft_range/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_range 2 | Expected files : ft_range.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following function: 7 | 8 | int *ft_range(int start, int end); 9 | 10 | It must allocate (with malloc()) an array of integers, fill it with consecutive 11 | values that begin at start and end at end (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 1, 2 and 3. 17 | - With (-1, 2) you will return an array containing -1, 0, 1 and 2. 18 | - With (0, 0) you will return an array containing 0. 19 | - With (0, -3) you will return an array containing 0, -1, -2 and -3. 20 | -------------------------------------------------------------------------------- /EXAM02/5-ft_range/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_range 2 | Expected files : ft_range.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following function: 7 | 8 | int *ft_range(int start, int end); 9 | 10 | It must allocate (with malloc()) an array of integers, fill it with consecutive 11 | values that begin at start and end at end (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 1, 2 and 3. 17 | - With (-1, 2) you will return an array containing -1, 0, 1 and 2. 18 | - With (0, 0) you will return an array containing 0. 19 | - With (0, -3) you will return an array containing 0, -1, -2 and -3. 20 | -------------------------------------------------------------------------------- /EXAM03/10-ft_range/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ft_range 2 | Expected files : ft_range.c 3 | Allowed functions: malloc 4 | -------------------------------------------------------------------------------- 5 | 6 | Write the following function: 7 | 8 | int *ft_range(int start, int end); 9 | 10 | It must allocate (with malloc()) an array of integers, fill it with consecutive 11 | values that begin at start and end at end (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 1, 2 and 3. 17 | - With (-1, 2) you will return an array containing -1, 0, 1 and 2. 18 | - With (0, 0) you will return an array containing 0. 19 | - With (0, -3) you will return an array containing 0, -1, -2 and -3. 20 | -------------------------------------------------------------------------------- /EXAM01/3-last_word/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : last_word 2 | Expected files : last_word.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays its last word followed by a \n. 7 | 8 | A word is a section of string delimited by spaces/tabs or by the start/end of 9 | the string. 10 | 11 | If the number of parameters is not 1, or there are no words, display a newline. 12 | 13 | Example: 14 | 15 | $> ./last_word "FOR PONY" | cat -e 16 | PONY$ 17 | $> ./last_word "this ... is sparta, then again, maybe not" | cat -e 18 | not$ 19 | $> ./last_word " " | cat -e 20 | $ 21 | $> ./last_word "a" "b" | cat -e 22 | $ 23 | $> ./last_word " lorem,ipsum " | cat -e 24 | lorem,ipsum$ 25 | $> 26 | -------------------------------------------------------------------------------- /EXAM02/3-last_word/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : last_word 2 | Expected files : last_word.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays its last word followed by a \n. 7 | 8 | A word is a section of string delimited by spaces/tabs or by the start/end of 9 | the string. 10 | 11 | If the number of parameters is not 1, or there are no words, display a newline. 12 | 13 | Example: 14 | 15 | $> ./last_word "FOR PONY" | cat -e 16 | PONY$ 17 | $> ./last_word "this ... is sparta, then again, maybe not" | cat -e 18 | not$ 19 | $> ./last_word " " | cat -e 20 | $ 21 | $> ./last_word "a" "b" | cat -e 22 | $ 23 | $> ./last_word " lorem,ipsum " | cat -e 24 | lorem,ipsum$ 25 | $> 26 | -------------------------------------------------------------------------------- /EXAM01/2-rot_13/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rot_13 2 | Expected files : rot_13.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays it, replacing each of its 7 | letters by the letter 13 spaces ahead in alphabetical order. 8 | 9 | 'z' becomes 'm' and 'Z' becomes 'M'. Case remains unaffected. 10 | 11 | The output will be followed by a newline. 12 | 13 | If the number of arguments is not 1, the program displays a newline. 14 | 15 | Example: 16 | 17 | $>./rot_13 "abc" 18 | nop 19 | $>./rot_13 "My horse is Amazing." | cat -e 20 | Zl ubefr vf Nznmvat.$ 21 | $>./rot_13 "AkjhZ zLKIJz , 23y " | cat -e 22 | NxwuM mYXVWm , 23l $ 23 | $>./rot_13 | cat -e 24 | $ 25 | $> 26 | $>./rot_13 "" | cat -e 27 | $ 28 | $> 29 | -------------------------------------------------------------------------------- /EXAM02/2-rot_13/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rot_13 2 | Expected files : rot_13.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays it, replacing each of its 7 | letters by the letter 13 spaces ahead in alphabetical order. 8 | 9 | 'z' becomes 'm' and 'Z' becomes 'M'. Case remains unaffected. 10 | 11 | The output will be followed by a newline. 12 | 13 | If the number of arguments is not 1, the program displays a newline. 14 | 15 | Example: 16 | 17 | $>./rot_13 "abc" 18 | nop 19 | $>./rot_13 "My horse is Amazing." | cat -e 20 | Zl ubefr vf Nznmvat.$ 21 | $>./rot_13 "AkjhZ zLKIJz , 23y " | cat -e 22 | NxwuM mYXVWm , 23l $ 23 | $>./rot_13 | cat -e 24 | $ 25 | $> 26 | $>./rot_13 "" | cat -e 27 | $ 28 | $> 29 | -------------------------------------------------------------------------------- /EXAM01/3-wdmatch/wdmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | write(1, &str[i], 1); 11 | i++; 12 | } 13 | } 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | i++; 22 | return (i); 23 | } 24 | 25 | int main(int ac, char **av) 26 | { 27 | int i; 28 | int j; 29 | int wdlen; 30 | 31 | i = 0; 32 | j = 0; 33 | wdlen = 0; 34 | if (ac == 3) 35 | { 36 | while (av[1][i] != '\0') 37 | { 38 | while (av[2][j] != '\0') 39 | { 40 | if (av[1][i] == av[2][j]) 41 | { 42 | wdlen++; 43 | break ; 44 | } 45 | j++; 46 | } 47 | i++; 48 | } 49 | if (wdlen == ft_strlen(av[1])) 50 | ft_putstr(av[1]); 51 | } 52 | write(1, "\n", 1); 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /EXAM02/3-wdmatch/wdmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | write(1, &str[i], 1); 11 | i++; 12 | } 13 | } 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | i++; 22 | return (i); 23 | } 24 | 25 | int main(int ac, char **av) 26 | { 27 | int i; 28 | int j; 29 | int wdlen; 30 | 31 | i = 0; 32 | j = 0; 33 | wdlen = 0; 34 | if (ac == 3) 35 | { 36 | while (av[1][i] != '\0') 37 | { 38 | while (av[2][j] != '\0') 39 | { 40 | if (av[1][i] == av[2][j]) 41 | { 42 | wdlen++; 43 | break ; 44 | } 45 | j++; 46 | } 47 | i++; 48 | } 49 | if (wdlen == ft_strlen(av[1])) 50 | ft_putstr(av[1]); 51 | } 52 | write(1, "\n", 1); 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /EXAM03/2-fizzbuzz/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : fizzbuzz 2 | Expected files : fizzbuzz.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Ecrire un programme qui écrit une suite de nombres de 1 à 100 sur la sortie 7 | standard, tous séparés par une newline. 8 | 9 | Si le nombre est un multiple de 3, le programme doit écrire 'fizz' à la place. 10 | 11 | Si le nombre est un multiple de 5, le programme doit écrire 'buzz' à la place. 12 | 13 | Si le nombre est un multiple de 3 et un multiple de 5, le programme doit écrire 14 | 'fizzbuzz' à la place. 15 | 16 | Exemple: 17 | 18 | $>./fizzbuzz 19 | 1 20 | 2 21 | fizz 22 | 4 23 | buzz 24 | fizz 25 | 7 26 | 8 27 | fizz 28 | buzz 29 | 11 30 | fizz 31 | 13 32 | 14 33 | fizzbuzz 34 | [...] 35 | 97 36 | 98 37 | fizz 38 | buzz 39 | $> -------------------------------------------------------------------------------- /EXAM01/2-first_word/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : first_word 2 | Expected files : first_word.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays its first word, followed by a 7 | newline. 8 | 9 | A word is a section of string delimited by spaces/tabs or by the start/end of 10 | the string. 11 | 12 | If the number of parameters is not 1, or if there are no words, simply display 13 | a newline. 14 | 15 | Examples: 16 | 17 | $> ./first_word "FOR PONY" | cat -e 18 | FOR$ 19 | $> ./first_word "this ... is sparta, then again, maybe not" | cat -e 20 | this$ 21 | $> ./first_word " " | cat -e 22 | $ 23 | $> ./first_word "a" "b" | cat -e 24 | $ 25 | $> ./first_word " lorem,ipsum " | cat -e 26 | lorem,ipsum$ 27 | $> 28 | -------------------------------------------------------------------------------- /EXAM02/2-first_word/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : first_word 2 | Expected files : first_word.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays its first word, followed by a 7 | newline. 8 | 9 | A word is a section of string delimited by spaces/tabs or by the start/end of 10 | the string. 11 | 12 | If the number of parameters is not 1, or if there are no words, simply display 13 | a newline. 14 | 15 | Examples: 16 | 17 | $> ./first_word "FOR PONY" | cat -e 18 | FOR$ 19 | $> ./first_word "this ... is sparta, then again, maybe not" | cat -e 20 | this$ 21 | $> ./first_word " " | cat -e 22 | $ 23 | $> ./first_word "a" "b" | cat -e 24 | $ 25 | $> ./first_word " lorem,ipsum " | cat -e 26 | lorem,ipsum$ 27 | $> 28 | -------------------------------------------------------------------------------- /EXAM01/2-rotone/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rotone 2 | Expected files : rotone.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays it, replacing each of its 7 | letters by the next one in alphabetical order. 8 | 9 | 'z' becomes 'a' and 'Z' becomes 'A'. Case remains unaffected. 10 | 11 | The output will be followed by a \n. 12 | 13 | If the number of arguments is not 1, the program displays \n. 14 | 15 | Example: 16 | 17 | $>./rotone "abc" 18 | bcd 19 | $>./rotone "Les stagiaires du staff ne sentent pas toujours tres bon." | cat -e 20 | Mft tubhjbjsft ev tubgg of tfoufou qbt upvkpvst usft cpo.$ 21 | $>./rotone "AkjhZ zLKIJz , 23y " | cat -e 22 | BlkiA aMLJKa , 23z $ 23 | $>./rotone | cat -e 24 | $ 25 | $> 26 | $>./rotone "" | cat -e 27 | $ 28 | $> 29 | -------------------------------------------------------------------------------- /EXAM01/3-union/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : union 2 | Expected files : union.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and displays, without doubles, the 7 | characters that appear in either one of the strings. 8 | 9 | The display will be in the order characters appear in the command line, and 10 | will be followed by a \n. 11 | 12 | If the number of arguments is not 2, the program displays \n. 13 | 14 | Example: 15 | 16 | $>./union zpadinton "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 17 | zpadintoqefwjy$ 18 | $>./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 19 | df6vewg4thras$ 20 | $>./union "rien" "cette phrase ne cache rien" | cat -e 21 | rienct phas$ 22 | $>./union | cat -e 23 | $ 24 | $> 25 | $>./union "rien" | cat -e 26 | $ 27 | $> 28 | -------------------------------------------------------------------------------- /EXAM02/2-rotone/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : rotone 2 | Expected files : rotone.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and displays it, replacing each of its 7 | letters by the next one in alphabetical order. 8 | 9 | 'z' becomes 'a' and 'Z' becomes 'A'. Case remains unaffected. 10 | 11 | The output will be followed by a \n. 12 | 13 | If the number of arguments is not 1, the program displays \n. 14 | 15 | Example: 16 | 17 | $>./rotone "abc" 18 | bcd 19 | $>./rotone "Les stagiaires du staff ne sentent pas toujours tres bon." | cat -e 20 | Mft tubhjbjsft ev tubgg of tfoufou qbt upvkpvst usft cpo.$ 21 | $>./rotone "AkjhZ zLKIJz , 23y " | cat -e 22 | BlkiA aMLJKa , 23z $ 23 | $>./rotone | cat -e 24 | $ 25 | $> 26 | $>./rotone "" | cat -e 27 | $ 28 | $> 29 | -------------------------------------------------------------------------------- /EXAM02/3-union/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : union 2 | Expected files : union.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and displays, without doubles, the 7 | characters that appear in either one of the strings. 8 | 9 | The display will be in the order characters appear in the command line, and 10 | will be followed by a \n. 11 | 12 | If the number of arguments is not 2, the program displays \n. 13 | 14 | Example: 15 | 16 | $>./union zpadinton "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 17 | zpadintoqefwjy$ 18 | $>./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 19 | df6vewg4thras$ 20 | $>./union "rien" "cette phrase ne cache rien" | cat -e 21 | rienct phas$ 22 | $>./union | cat -e 23 | $ 24 | $> 25 | $>./union "rien" | cat -e 26 | $ 27 | $> 28 | -------------------------------------------------------------------------------- /EXAM03/9-union/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : union 2 | Expected files : union.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and displays, without doubles, the 7 | characters that appear in either one of the strings. 8 | 9 | The display will be in the order characters appear in the command line, and 10 | will be followed by a \n. 11 | 12 | If the number of arguments is not 2, the program displays \n. 13 | 14 | Example: 15 | 16 | $>./union zpadinton "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e 17 | zpadintoqefwjy$ 18 | $>./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e 19 | df6vewg4thras$ 20 | $>./union "rien" "cette phrase ne cache rien" | cat -e 21 | rienct phas$ 22 | $>./union | cat -e 23 | $ 24 | $> 25 | $>./union "rien" | cat -e 26 | $ 27 | $> 28 | -------------------------------------------------------------------------------- /EXAM03/13-count_alpha/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : count_alpha 2 | Expected files : count_alpha.c 3 | Allowed functions: write, printf 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme count_alpha qui prend une chaîne et affiche le nombre d'occurences 7 | de ses caractères alphabétiques. Les autres caractères ne sont pas comptés. L'ordre est l'ordre d'apparition dans la chaîne. 8 | L'affichage doit être terminé par un newline. 9 | 10 | Le format est dans les exemples. 11 | 12 | Si le nombre d'arguments n'est pas 1, afficher juste un newline. 13 | 14 | Exemples : 15 | $> ./count_alpha abbcc 16 | 1a, 2b, 2c 17 | $> ./count_alpha "abbcc" 18 | 1a, 2b, 2c 19 | $> ./count_alpha "abbcc" "dddeef" | cat -e 20 | $ 21 | $> ./count_alpha "My Hyze 47y 7." | cat -e 22 | 1m, 3y, 1h, 1z, 1e$ 23 | $> ./count_alpha "" | cat -e 24 | $ -------------------------------------------------------------------------------- /C06/ex03/ft_sort_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sort_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/29 21:14:36 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/29 22:13:51 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | -------------------------------------------------------------------------------- /EXAM01/3-wdmatch/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : wdmatch 2 | Expected files : wdmatch.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and checks whether it's possible to 7 | write the first string with characters from the second string, while respecting 8 | the order in which these characters appear in the second string. 9 | 10 | If it's possible, the program displays the string, followed by a \n, otherwise 11 | it simply displays a \n. 12 | 13 | If the number of arguments is not 2, the program displays a \n. 14 | 15 | Examples: 16 | 17 | $>./wdmatch "faya" "fgvvfdxcacpolhyghbreda" | cat -e 18 | faya$ 19 | $>./wdmatch "faya" "fgvvfdxcacpolhyghbred" | cat -e 20 | $ 21 | $>./wdmatch "quarante deux" "qfqfsudf arzgsayns tsregfdgs sjytdekuoixq " | cat -e 22 | quarante deux$ 23 | $>./wdmatch "error" rrerrrfiiljdfxjyuifrrvcoojh | cat -e 24 | $ 25 | $>./wdmatch | cat -e 26 | $ 27 | -------------------------------------------------------------------------------- /EXAM02/3-wdmatch/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : wdmatch 2 | Expected files : wdmatch.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes two strings and checks whether it's possible to 7 | write the first string with characters from the second string, while respecting 8 | the order in which these characters appear in the second string. 9 | 10 | If it's possible, the program displays the string, followed by a \n, otherwise 11 | it simply displays a \n. 12 | 13 | If the number of arguments is not 2, the program displays a \n. 14 | 15 | Examples: 16 | 17 | $>./wdmatch "faya" "fgvvfdxcacpolhyghbreda" | cat -e 18 | faya$ 19 | $>./wdmatch "faya" "fgvvfdxcacpolhyghbred" | cat -e 20 | $ 21 | $>./wdmatch "quarante deux" "qfqfsudf arzgsayns tsregfdgs sjytdekuoixq " | cat -e 22 | quarante deux$ 23 | $>./wdmatch "error" rrerrrfiiljdfxjyuifrrvcoojh | cat -e 24 | $ 25 | $>./wdmatch | cat -e 26 | $ 27 | -------------------------------------------------------------------------------- /EXAM03/6-ulstr/subject.en.txt: -------------------------------------------------------------------------------- 1 | Assignment name : ulstr 2 | Expected files : ulstr.c 3 | Allowed functions: write 4 | -------------------------------------------------------------------------------- 5 | 6 | Write a program that takes a string and reverses the case of all its letters. 7 | Other characters remain unchanged. 8 | 9 | You must display the result followed by a '\n'. 10 | 11 | If the number of arguments is not 1, the program displays '\n'. 12 | 13 | Examples : 14 | 15 | $>./ulstr "L'eSPrit nE peUt plUs pRogResSer s'Il staGne et sI peRsIsTent VAnIte et auto-justification." | cat -e 16 | l'EspRIT Ne PEuT PLuS PrOGrESsER S'iL STAgNE ET Si PErSiStENT vaNiTE ET AUTO-JUSTIFICATION.$ 17 | $>./ulstr "S'enTOuRer dE sECreT eSt uN sIGnE De mAnQuE De coNNaiSSanCe. " | cat -e 18 | s'ENtoUrER De SecREt EsT Un SigNe dE MaNqUe dE COnnAIssANcE. $ 19 | $>./ulstr "3:21 Ba tOut moUn ki Ka di KE m'en Ka fe fot" | cat -e 20 | 3:21 bA ToUT MOuN KI kA DI ke M'EN kA FE FOT$ 21 | $>./ulstr | cat -e 22 | $ 23 | -------------------------------------------------------------------------------- /C00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/11 22:01:27 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/11 22:06:31 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /EXAM01/3-union/union.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_doubles2(char *str, char c) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | if (str[i] == c) 11 | return (0); 12 | i++; 13 | } 14 | return (1); 15 | } 16 | 17 | int check_doubles1(char *str, char c, int pos) 18 | { 19 | int i; 20 | 21 | i = 0; 22 | while (i < pos) 23 | { 24 | if (str[i] == c) 25 | return (0); 26 | i++; 27 | } 28 | return (1); 29 | } 30 | 31 | void ft_union(char *str, char *str1) 32 | { 33 | int i; 34 | 35 | i = 0; 36 | while (str[i] != '\0') 37 | { 38 | if (check_doubles1(str, str[i], i) == 1) 39 | write(1, &str[i], 1); 40 | i++; 41 | } 42 | i = 0; 43 | while (str1[i] != '\0') 44 | { 45 | if (check_doubles2(str, str1[i]) == 1) 46 | { 47 | if (check_doubles1(str1, str1[i], i) == 1) 48 | write(1, &str1[i], 1); 49 | } 50 | i++; 51 | } 52 | } 53 | 54 | int main(int ac, char **av) 55 | { 56 | if (ac == 3) 57 | ft_union(av[1], av[2]); 58 | write(1, "\n", 1); 59 | return (0); 60 | } 61 | -------------------------------------------------------------------------------- /EXAM02/3-union/union.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_doubles2(char *str, char c) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | if (str[i] == c) 11 | return (0); 12 | i++; 13 | } 14 | return (1); 15 | } 16 | 17 | int check_doubles1(char *str, char c, int pos) 18 | { 19 | int i; 20 | 21 | i = 0; 22 | while (i < pos) 23 | { 24 | if (str[i] == c) 25 | return (0); 26 | i++; 27 | } 28 | return (1); 29 | } 30 | 31 | void ft_union(char *str, char *str1) 32 | { 33 | int i; 34 | 35 | i = 0; 36 | while (str[i] != '\0') 37 | { 38 | if (check_doubles1(str, str[i], i) == 1) 39 | write(1, &str[i], 1); 40 | i++; 41 | } 42 | i = 0; 43 | while (str1[i] != '\0') 44 | { 45 | if (check_doubles2(str, str1[i]) == 1) 46 | { 47 | if (check_doubles1(str1, str1[i], i) == 1) 48 | write(1, &str1[i], 1); 49 | } 50 | i++; 51 | } 52 | } 53 | 54 | int main(int ac, char **av) 55 | { 56 | if (ac == 3) 57 | ft_union(av[1], av[2]); 58 | write(1, "\n", 1); 59 | return (0); 60 | } 61 | -------------------------------------------------------------------------------- /EXAM03/9-union/unionmomou.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_doubles2(char *str, char c) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | if (str[i] == c) 11 | return (0); 12 | i++; 13 | } 14 | return (1); 15 | } 16 | 17 | int check_doubles1(char *str, char c, int pos) 18 | { 19 | int i; 20 | 21 | i = 0; 22 | while (i < pos) 23 | { 24 | if (str[i] == c) 25 | return (0); 26 | i++; 27 | } 28 | return (1); 29 | } 30 | 31 | void ft_union(char *str, char *str1) 32 | { 33 | int i; 34 | 35 | i = 0; 36 | while (str[i] != '\0') 37 | { 38 | if (check_doubles1(str, str[i], i) == 1) 39 | write(1, &str[i], 1); 40 | i++; 41 | } 42 | i = 0; 43 | while (str1[i] != '\0') 44 | { 45 | if (check_doubles2(str, str1[i]) == 1) 46 | { 47 | if (check_doubles1(str1, str1[i], i) == 1) 48 | write(1, &str1[i], 1); 49 | } 50 | i++; 51 | } 52 | } 53 | 54 | int main(int ac, char **av) 55 | { 56 | if (ac == 3) 57 | ft_union(av[1], av[2]); 58 | write(1, "\n", 1); 59 | return (0); 60 | } 61 | -------------------------------------------------------------------------------- /C00/ex01/ft_print_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/11 22:45:40 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/12 09:38:30 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_alphabet(void) 16 | { 17 | write(1, "abcdefghijklmnopqrstuvwxyz", 26); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex04/ft_is_negative.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_negative.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/12 10:48:53 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/12 11:56:55 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_is_negative(int n) 16 | { 17 | if (n >= 0) 18 | write(1, "P", 1); 19 | else 20 | write(1, "N", 1); 21 | } 22 | -------------------------------------------------------------------------------- /C04/ex00/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/22 14:48:06 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/22 15:01:38 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | i++; 23 | } 24 | return (i); 25 | } 26 | -------------------------------------------------------------------------------- /EXAM03/12-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 | -------------------------------------------------------------------------------- /C04/ex01/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/22 15:02:13 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/22 15:07:51 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | write(1, &str[i], 1); 23 | i++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C00/ex03/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_numbers.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/12 10:07:10 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/13 21:28:18 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_numbers(void) 16 | { 17 | int num; 18 | 19 | num = '0'; 20 | while (num <= '9') 21 | { 22 | write(1, &num, 1); 23 | num++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C01/ex00/ft_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/15 21:49:50 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/16 23:27:00 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | 15 | void ft_ft(int *nbr) 16 | { 17 | *nbr = 42; 18 | } 19 | /* 20 | int main() 21 | { 22 | int a; 23 | ft_ft(&a); 24 | printf("%d",a ); 25 | 26 | }*/ 27 | -------------------------------------------------------------------------------- /C01/ex06/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/17 01:32:09 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/17 13:22:13 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strlen(char *str) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (str[i] != '\0') 22 | { 23 | i++; 24 | } 25 | return (i); 26 | } 27 | -------------------------------------------------------------------------------- /C00/ex02/ft_print_reverse_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_reverse_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/12 09:40:18 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/12 10:05:46 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_reverse_alphabet(void) 16 | { 17 | int z; 18 | 19 | z = 'z'; 20 | while (z >= 'a') 21 | { 22 | write (1, &z, 1); 23 | z--; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex06/ft_is_prime.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_prime.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/11/01 22:54:11 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/01 23:12:44 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_is_prime(int nb) 14 | { 15 | int x; 16 | 17 | x = 2; 18 | if (nb <= 1) 19 | { 20 | return (0); 21 | } 22 | while (x < nb) 23 | { 24 | if ((nb % x) == 0) 25 | return (0); 26 | x++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C05/ex05/ft_sqrt.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sqrt.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/11/01 22:49:34 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/01 23:21:52 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_sqrt(int nb) 14 | { 15 | int i; 16 | int t; 17 | 18 | t = nb; 19 | i = 2; 20 | while (t == 1 || i == 0) 21 | return (t); 22 | while (i * i <= t) 23 | { 24 | if (t == i * i) 25 | return (i); 26 | i++; 27 | } 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /EXAM01/4-ft_range/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_abs(int x) 4 | { 5 | if (x < 0) 6 | return (-x); 7 | return (x); 8 | } 9 | 10 | int *ft_range(int start, int end) 11 | { 12 | int size; 13 | int i; 14 | int *tab; 15 | int *d; 16 | 17 | size = ft_abs(end - start) + 1; 18 | d = (tab = malloc(size * sizeof(int))); 19 | if (!d) 20 | return (0); 21 | i = 0; 22 | if ( size == 1) 23 | tab[0] = start; 24 | if (start < end) 25 | { 26 | while (i < size) 27 | { 28 | tab[i] = start + i; 29 | i++; 30 | } 31 | } 32 | else if (start > end) 33 | { 34 | while (i < size) 35 | { 36 | tab[i] = start - i; 37 | i++; 38 | } 39 | } 40 | return (tab); 41 | } 42 | 43 | int main(void) 44 | { 45 | int *tab; 46 | int i = 0; 47 | int start = 0; 48 | int end = 0 ; 49 | int size = ft_abs(end - start) + 1; 50 | 51 | tab = ft_range(start, end); 52 | while(i < size) 53 | { 54 | printf("%i, ", tab[i]); 55 | i++; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /EXAM02/5-ft_range/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_abs(int x) 4 | { 5 | if (x < 0) 6 | return (-x); 7 | return (x); 8 | } 9 | 10 | int *ft_range(int start, int end) 11 | { 12 | int size; 13 | int i; 14 | int *tab; 15 | int *d; 16 | 17 | size = ft_abs(end - start) + 1; 18 | d = (tab = malloc(size * sizeof(int))); 19 | if (!d) 20 | return (0); 21 | i = 0; 22 | if ( size == 1) 23 | tab[0] = start; 24 | if (start < end) 25 | { 26 | while (i < size) 27 | { 28 | tab[i] = start + i; 29 | i++; 30 | } 31 | } 32 | else if (start > end) 33 | { 34 | while (i < size) 35 | { 36 | tab[i] = start - i; 37 | i++; 38 | } 39 | } 40 | return (tab); 41 | } 42 | 43 | int main(void) 44 | { 45 | int *tab; 46 | int i = 0; 47 | int start = 0; 48 | int end = 0 ; 49 | int size = ft_abs(end - start) + 1; 50 | 51 | tab = ft_range(start, end); 52 | while(i < size) 53 | { 54 | printf("%i, ", tab[i]); 55 | i++; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /EXAM03/10-ft_range/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_abs(int x) 4 | { 5 | if (x < 0) 6 | return (-x); 7 | return (x); 8 | } 9 | 10 | int *ft_range(int start, int end) 11 | { 12 | int size; 13 | int i; 14 | int *tab; 15 | int *d; 16 | 17 | size = ft_abs(end - start) + 1; 18 | d = (tab = malloc(size * sizeof(int))); 19 | if (!d) 20 | return (0); 21 | i = 0; 22 | if ( size == 1) 23 | tab[0] = start; 24 | if (start < end) 25 | { 26 | while (i < size) 27 | { 28 | tab[i] = start + i; 29 | i++; 30 | } 31 | } 32 | else if (start > end) 33 | { 34 | while (i < size) 35 | { 36 | tab[i] = start - i; 37 | i++; 38 | } 39 | } 40 | return (tab); 41 | } 42 | 43 | int main(void) 44 | { 45 | int *tab; 46 | int i = 0; 47 | int start = 0; 48 | int end = 0 ; 49 | int size = ft_abs(end - start) + 1; 50 | 51 | tab = ft_range(start, end); 52 | while(i < size) 53 | { 54 | printf("%i, ", tab[i]); 55 | i++; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /EXAM03/14-str-maxlenoc/subject.fr.txt: -------------------------------------------------------------------------------- 1 | Assignment name : str_maxlenoc 2 | Expected files : str_maxlenoc.c 3 | Allowed functions: write, malloc, free 4 | -------------------------------------------------------------------------------- 5 | 6 | Écrire un programme qui prend en paramètres n chaînes de caractères et qui 7 | affiche, suivie d'un retour à la ligne, la plus grande chaîne de caractères 8 | incluse dans toutes les chaînes passées en paramètres. Si plusieurs chaînes 9 | correspondent, on affichera celle qui apparaît en premier dans le premier 10 | paramètre. A noter que "" est forcément dans toutes les chaînes. 11 | 12 | Si aucun paramètre n'est transmis, le programme doit afficher 13 | '\n'. 14 | 15 | Soit A et B des chaînes de caracteres. On dit que A 16 | est inclus dans B si A est une sous-chaîne de B ou 17 | si A et B sont identiques. 18 | 19 | Exemples : 20 | $>./str_maxlenoc ab bac abacabccabcb 21 | a 22 | $>./str_maxlenoc bonjour salut bonjour bonjour 23 | u 24 | $>./str_maxlenoc xoxAoxo xoxAox oxAox oxo A ooxAoxx oxooxo Axo | cat -e 25 | $ 26 | $>./str_maxlenoc bosdsdfnjodur atehhellosd afkuonjosurafg headfgllosf fghellosag afdfbosnjourafg 27 | os 28 | $>./str_maxlenoc | cat -e 29 | $ -------------------------------------------------------------------------------- /C02/ex00/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/17 15:25:03 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/20 21:22:57 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strcpy(char *dest, char *src) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (src[i] != '\0') 22 | { 23 | dest[i] = src[i]; 24 | i++; 25 | } 26 | dest[i] = '\0'; 27 | return (dest); 28 | } 29 | -------------------------------------------------------------------------------- /C02/ex07/ft_strupcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strupcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 20:07:55 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 19:35:56 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | char *ft_strupcase(char *str) 15 | { 16 | int i; 17 | 18 | i = 0; 19 | while (str[i] != '\0') 20 | { 21 | if (str[i] >= 'a' && str[i] <= 'z') 22 | { 23 | str[i] -= 32; 24 | } 25 | i++; 26 | } 27 | return (str); 28 | } 29 | -------------------------------------------------------------------------------- /C06/ex00/ft_print_program_name.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_program_name.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/29 16:25:21 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/29 16:35:25 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | 19 | (void)ac; 20 | i = 0; 21 | while (av[0][i] != '\0') 22 | { 23 | write(1, &av[0][i], 1); 24 | i++; 25 | } 26 | write(1, "\n", 1); 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /C01/ex02/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/16 15:55:04 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/16 23:30:19 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_swap(int *a, int *b) 16 | { 17 | int vid; 18 | 19 | vid = *a; 20 | *a = *b; 21 | *b = vid; 22 | } 23 | /* 24 | int main() 25 | { 26 | int x = 1337; 27 | int y = 42; 28 | ft_swap(&x,&y); 29 | printf("%d %d", x, y); 30 | } 31 | */ 32 | -------------------------------------------------------------------------------- /C02/ex04/ft_str_is_lowercase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_lowercase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 16:40:55 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 18:10:09 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_lowercase(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (!(str[i] >= 'a' && str[i] <= 'z')) 23 | { 24 | return (0); 25 | } 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex05/ft_str_is_uppercase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_uppercase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 16:50:52 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 19:10:32 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_uppercase(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (!(str[i] >= 'A' && str[i] <= 'Z')) 23 | { 24 | return (0); 25 | } 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex06/ft_str_is_printable.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_printable.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 19:52:20 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/19 01:10:51 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_printable(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (!(str[i] >= ' ' && str[i] <= '~')) 23 | { 24 | return (0); 25 | } 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C05/ex04/ft_fibonacci.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fibonacci.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/31 17:32:02 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/01 18:07:35 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_fibonacci(int index) 17 | { 18 | if (index == 1) 19 | return (1); 20 | if (index == 0) 21 | return (0); 22 | if (index < 0) 23 | return (-1); 24 | return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2)); 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex01/ft_recursive_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/31 23:12:10 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/31 23:44:09 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_recursive_factorial(int nb) 17 | { 18 | int f; 19 | 20 | f = 1; 21 | if (nb < 0) 22 | return (0); 23 | else if (nb == 0) 24 | return (1); 25 | else 26 | return (nb * ft_recursive_factorial(nb - 1)); 27 | } 28 | -------------------------------------------------------------------------------- /C01/ex03/ft_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/16 17:44:19 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/16 23:34:05 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_div_mod(int a, int b, int *div, int *mod) 16 | { 17 | *div = (a / b); 18 | *mod = (a % b); 19 | } 20 | 21 | /* 22 | int main(void) 23 | { 24 | int div; 25 | int mod; 26 | 27 | ft_div_mod(10, 5, &div, &mod); 28 | printf("%d %d", div, mod); 29 | } 30 | */ 31 | -------------------------------------------------------------------------------- /C02/ex03/ft_str_is_numeric.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_numeric.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 16:31:19 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 21:19:35 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_str_is_numeric(char *str) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (str[i] != '\0') 22 | { 23 | if (!(str[i] >= '0' && str[i] <= '9')) 24 | { 25 | return (0); 26 | } 27 | i++; 28 | } 29 | return (1); 30 | } 31 | -------------------------------------------------------------------------------- /C03/ex00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/23 15:47:00 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/02 12:52:42 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strcmp(char *s1, char *s2) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (s1[i] != '\0' || s2[i] != '\0') 22 | { 23 | if (s1[i] != s2[i]) 24 | { 25 | return (s1[i] - s2[i]); 26 | } 27 | i++; 28 | } 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /C05/ex00/ft_iterative_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/29 22:29:56 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/31 21:56:10 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | 15 | int ft_iterative_factorial(int nb) 16 | { 17 | int f; 18 | 19 | f = 1; 20 | if (nb < 0) 21 | return (0); 22 | else if (nb == 0) 23 | return (1); 24 | while (nb > 1) 25 | { 26 | f = f * nb; 27 | nb--; 28 | } 29 | return (f); 30 | } 31 | -------------------------------------------------------------------------------- /C06/ex01/ft_print_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/29 16:37:23 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/29 18:20:55 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | int j; 19 | 20 | j = 1; 21 | while (av[j] != '\0' && j < ac) 22 | { 23 | write(1, &av[j][i], 1); 24 | i++; 25 | if (av[j][i] == '\0') 26 | { 27 | i = 0; 28 | write(1, "\n", 1); 29 | j++; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /C00/ex07/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/12 16:05:50 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/24 17:05:25 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_putnbr(int n) 21 | { 22 | long int nb; 23 | 24 | nb = n; 25 | if (nb < 0) 26 | { 27 | ft_putchar('-'); 28 | nb *= -1; 29 | } 30 | if (nb > 9) 31 | ft_putnbr(nb / 10); 32 | ft_putchar(nb % 10 + 48); 33 | } 34 | -------------------------------------------------------------------------------- /C02/ex02/ft_str_is_alpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_alpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/17 19:08:18 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/02 12:47:20 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_alpha(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (!((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' 23 | && str[i] <= 'z'))) 24 | { 25 | return (0); 26 | } 27 | i++; 28 | } 29 | return (1); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /C06/ex02/ft_rev_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rev_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/29 18:24:46 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/29 19:31:41 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | int j; 19 | 20 | j = ac - 1; 21 | while (j > 0) 22 | { 23 | i = 0; 24 | while (av[j][i] != '\0') 25 | { 26 | write(1, &av[j][i], 1); 27 | i++; 28 | } 29 | j--; 30 | write(1, "\n", 1); 31 | } 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /C05/ex02/ft_iterative_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/31 23:44:57 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/02 01:44:12 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | 15 | int ft_iterative_power(int nb, int power) 16 | { 17 | int x; 18 | 19 | x = 1; 20 | if (power < 0) 21 | return (0); 22 | if (power == 0 && nb == 0) 23 | return (1); 24 | while (power > 0) 25 | { 26 | x = x * nb; 27 | power--; 28 | } 29 | return (x); 30 | } 31 | -------------------------------------------------------------------------------- /C05/ex03/ft_recursive_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/11/01 19:17:49 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/01 20:12:55 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_recursive_power(int nb, int power) 17 | { 18 | if (power < 0) 19 | return (0); 20 | if (power == 0) 21 | return (1); 22 | while (power > 0) 23 | { 24 | return (nb * ft_recursive_power(nb, power - 1)); 25 | power--; 26 | } 27 | return (nb); 28 | } 29 | -------------------------------------------------------------------------------- /C04/ex02/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/22 15:08:59 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/27 21:22:40 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_putnbr(int nb) 21 | { 22 | long int n; 23 | 24 | n = nb; 25 | if (n < 0) 26 | { 27 | write(1, "-", 1); 28 | n *= -1; 29 | } 30 | if (n > 9) 31 | { 32 | ft_putnbr(n / 10); 33 | } 34 | ft_putchar((n % 10) + '0'); 35 | } 36 | -------------------------------------------------------------------------------- /C02/ex01/ft_strncpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/19 00:29:20 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 19:02:52 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strncpy(char *dest, char *src, unsigned int n) 17 | { 18 | unsigned int i; 19 | 20 | i = 0; 21 | while (src[i] != '\0' && i < n) 22 | { 23 | dest[i] = src[i]; 24 | i++; 25 | } 26 | while (i < n) 27 | { 28 | dest[i] = '\0'; 29 | i++; 30 | } 31 | return (dest); 32 | } 33 | -------------------------------------------------------------------------------- /C03/ex02/ft_strcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/24 09:26:15 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/24 11:11:55 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strcat(char *dest, char *src) 17 | { 18 | int i; 19 | int j; 20 | 21 | i = 0; 22 | j = 0; 23 | while (dest[i] != '\0') 24 | { 25 | i++; 26 | } 27 | while (src[j] != '\0') 28 | { 29 | dest[i + j] = src[j]; 30 | j++; 31 | } 32 | dest[i + j] = '\0'; 33 | return (dest); 34 | } 35 | -------------------------------------------------------------------------------- /C03/ex01/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/23 18:29:34 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/25 15:31:28 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int ft_strncmp(char *s1, char *s2, unsigned int n) 18 | { 19 | unsigned int i; 20 | 21 | i = 0; 22 | while ((s1[i] != '\0' || s2[i] != '\0') && i < n) 23 | { 24 | if (s1[i] != s2[i]) 25 | { 26 | return (s1[i] - s2[i]); 27 | } 28 | i++; 29 | } 30 | return (0); 31 | } 32 | -------------------------------------------------------------------------------- /C01/ex05/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/16 23:38:01 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/17 14:10:14 by amezioun ### ########.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] != '\0') 26 | { 27 | ft_putchar(str[i]); 28 | i++; 29 | } 30 | } 31 | /* 32 | 33 | int main() 34 | { 35 | char str[] = "hjadsdshds"; 36 | ft_putstr(str); 37 | 38 | } 39 | */ 40 | -------------------------------------------------------------------------------- /C01/ex04/ft_ultimate_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/17 00:58:35 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/17 01:09:50 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_ultimate_div_mod(int *a, int *b) 16 | { 17 | int vid; 18 | 19 | vid = *a / *b; 20 | *b = *a % *b; 21 | *a = vid; 22 | } 23 | /* 24 | int main(void) 25 | { 26 | int a; 27 | int b; 28 | 29 | a = 10; 30 | b = 3; 31 | ft_ultimate_div_mod(&a, &b); 32 | printf("a is %d\n", a); 33 | printf("b is %d\n", b); 34 | } 35 | */ 36 | -------------------------------------------------------------------------------- /C02/ex08/ft_strlowcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlowcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/18 23:43:18 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/21 22:18:18 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strlowcase(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (str[i] >= 'A' && str[i] <= 'Z') 23 | { 24 | str[i] += 32; 25 | } 26 | i++; 27 | } 28 | return (str); 29 | } 30 | /* 31 | int main(void) 32 | { 33 | char asdf[] = "23_-3frewg4wvfsd4"; 34 | 35 | ft_strlowcase(asdf); 36 | } 37 | */ 38 | -------------------------------------------------------------------------------- /C03/ex04/ft_strstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/25 14:20:41 by amezioun #+# #+# */ 9 | /* Updated: 2023/11/02 12:51:49 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | 15 | char *ft_strstr(char *str, char *to_find) 16 | { 17 | int i; 18 | int j; 19 | int k; 20 | 21 | i = 0; 22 | while (to_find[i] != '\0') 23 | i++; 24 | if (i == 0) 25 | return (str); 26 | j = 0; 27 | while (str[j] != '\0') 28 | { 29 | k = 0; 30 | while (str[j + k] == to_find[k]) 31 | { 32 | k++; 33 | if (k == i) 34 | return (&str[j]); 35 | } 36 | j++; 37 | } 38 | return (0); 39 | } 40 | -------------------------------------------------------------------------------- /C01/ex01/ft_ultimate_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/15 21:51:20 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/16 23:30:47 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | 15 | void ft_ultimate_ft(int *********nbr) 16 | { 17 | *********nbr = 42; 18 | } 19 | 20 | /* 21 | int main() 22 | { 23 | int a = 5; 24 | int *p1 = &a ; 25 | int **p2 = &p1; 26 | int ***p3 = &p2; 27 | int ****p4 = &p3; 28 | int *****p5 = &p4; 29 | int ******p6 = &p5; 30 | int *******p7 = &p6; 31 | int ********p8 = &p7; 32 | int *********p9 = &p8; 33 | 34 | 35 | 36 | ft_ultimate_ft(p9); 37 | printf("%d", a); 38 | } 39 | */ 40 | -------------------------------------------------------------------------------- /C03/ex03/ft_strncat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/24 11:12:45 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/24 12:25:55 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strncat(char *dest, char *src, unsigned int nb) 17 | { 18 | unsigned int i; 19 | unsigned int j; 20 | 21 | i = 0; 22 | j = 0; 23 | while (dest[i] != '\0') 24 | { 25 | i++; 26 | } 27 | while (src[j] != '\0' && j < nb) 28 | { 29 | dest[i + j] = src[j]; 30 | j++; 31 | } 32 | dest[i + j] = '\0'; 33 | return (dest); 34 | } 35 | /* 36 | int main(void) 37 | { 38 | char src[] = "achraf"; 39 | char dest[] = "amine"; 40 | printf("%s", ft_strncat(dest, src, 5)); 41 | }*/ 42 | -------------------------------------------------------------------------------- /C00/ex06/ft_print_comb2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/13 20:31:01 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/13 21:19:04 by amezioun ### ########.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_comb2(void) 21 | { 22 | int comb0; 23 | int comb1; 24 | 25 | comb0 = 0; 26 | while (comb0 <= 98) 27 | { 28 | comb1 = comb0 + 1; 29 | while (comb1 <= 99) 30 | { 31 | ft_putchar((comb0) / 10 + '0'); 32 | ft_putchar((comb0) % 10 + '0'); 33 | write(1, " ", 1); 34 | ft_putchar((comb1) / 10 + '0'); 35 | ft_putchar((comb1) % 10 + '0'); 36 | if (!(comb0 == 98 && comb1 == 99)) 37 | write(1, ", ", 2); 38 | comb1++; 39 | } 40 | comb0++; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /C00/ex05/ft_print_comb.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/11 17:38:24 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/12 12:16:56 by amezioun ### ########.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_comb(void) 21 | { 22 | int numb0; 23 | int numb1; 24 | int numb2; 25 | 26 | numb0 = 0; 27 | while (numb0 <= '7') 28 | { 29 | numb1 = numb0 + 1; 30 | while (numb1 <= '8') 31 | { 32 | numb2 = numb1 + 1; 33 | while (numb2 <= 9) 34 | { 35 | ft_putchar (numb0 + '0'); 36 | ft_putchar (numb1 + '0'); 37 | ft_putchar (numb2 + '0'); 38 | if (numb0 != 7) 39 | write (1, ", ", 2); 40 | numb2++; 41 | } 42 | numb1++; 43 | } 44 | numb0++; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /C04/ex03/ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/25 18:50:47 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/27 21:42:10 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_atoi(char *str) 17 | { 18 | int countminus; 19 | int number; 20 | 21 | countminus = 0; 22 | while ((*str != '\0' && *str == ' ') || (*str != '\0' && *str >= 9 23 | && *str <= 13)) 24 | { 25 | str++; 26 | } 27 | while (*str == '-' || *str == '+') 28 | { 29 | if (*str == '-') 30 | countminus++; 31 | str++; 32 | } 33 | number = 0; 34 | while (*str != '\0' && *str >= '0' && *str <= '9') 35 | { 36 | number = number * 10 + (*str - '0'); 37 | str++; 38 | } 39 | if (!((countminus % 2) == 0)) 40 | return (-number); 41 | return (number); 42 | } 43 | -------------------------------------------------------------------------------- /EXAM01/5-ft_split/ft_split.c: -------------------------------------------------------------------------------- 1 | #include 2 | int check_separator(char c) 3 | { 4 | if ( c == 10 || c == 9 || c == 32) 5 | return (1); 6 | if (c == 0) 7 | return (1); 8 | return (0); 9 | } 10 | 11 | int count_strings(char *str) 12 | { 13 | int i; 14 | int count; 15 | 16 | count = 0; 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | while (str[i] != '\0' && check_separator(str[i])) 21 | i++; 22 | if (str[i] != '\0') 23 | count++; 24 | while (str[i] != '\0' && !check_separator(str[i])) 25 | i++; 26 | } 27 | return (count); 28 | } 29 | 30 | int ft_strlen_sep(char *str) 31 | { 32 | int i; 33 | 34 | i = 0; 35 | while (str[i] && !check_separator(str[i])) 36 | i++; 37 | return (i); 38 | } 39 | 40 | char *ft_word(char *str) 41 | { 42 | int len_word; 43 | int i; 44 | char *word; 45 | 46 | i = 0; 47 | len_word = ft_strlen_sep(str); 48 | word = (char *)malloc(sizeof(char) * (len_word + 1)); 49 | while (i < len_word) 50 | { 51 | word[i] = str[i]; 52 | i++; 53 | } 54 | word[i] = '\0'; 55 | return (word); 56 | } 57 | 58 | char **ft_split(char *str) 59 | { 60 | char **strings; 61 | int i; 62 | 63 | i = 0; 64 | strings = (char **)malloc(sizeof(char *) 65 | * (count_strings(str) + 1)); 66 | while (*str != '\0') 67 | { 68 | while (*str != '\0' && check_separator(*str)) 69 | str++; 70 | if (*str != '\0') 71 | { 72 | strings[i] = ft_word(str); 73 | i++; 74 | } 75 | while (*str && !check_separator(*str)) 76 | str++; 77 | } 78 | strings[i] = 0; 79 | return (strings); 80 | } 81 | 82 | #include 83 | int main(int argc, char **argv) 84 | { 85 | int index; 86 | char **split; 87 | (void) argc; 88 | split = ft_split(argv[1]); 89 | index = 0; 90 | while (split[index]) 91 | { 92 | printf("%s\n", split[index]); 93 | index++; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /EXAM02/6-ft_split/ft_split.c: -------------------------------------------------------------------------------- 1 | #include 2 | int check_separator(char c) 3 | { 4 | if ( c == 10 || c == 9 || c == 32) 5 | return (1); 6 | if (c == 0) 7 | return (1); 8 | return (0); 9 | } 10 | 11 | int count_strings(char *str) 12 | { 13 | int i; 14 | int count; 15 | 16 | count = 0; 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | while (str[i] != '\0' && check_separator(str[i])) 21 | i++; 22 | if (str[i] != '\0') 23 | count++; 24 | while (str[i] != '\0' && !check_separator(str[i])) 25 | i++; 26 | } 27 | return (count); 28 | } 29 | 30 | int ft_strlen_sep(char *str) 31 | { 32 | int i; 33 | 34 | i = 0; 35 | while (str[i] && !check_separator(str[i])) 36 | i++; 37 | return (i); 38 | } 39 | 40 | char *ft_word(char *str) 41 | { 42 | int len_word; 43 | int i; 44 | char *word; 45 | 46 | i = 0; 47 | len_word = ft_strlen_sep(str); 48 | word = (char *)malloc(sizeof(char) * (len_word + 1)); 49 | while (i < len_word) 50 | { 51 | word[i] = str[i]; 52 | i++; 53 | } 54 | word[i] = '\0'; 55 | return (word); 56 | } 57 | 58 | char **ft_split(char *str) 59 | { 60 | char **strings; 61 | int i; 62 | 63 | i = 0; 64 | strings = (char **)malloc(sizeof(char *) 65 | * (count_strings(str) + 1)); 66 | while (*str != '\0') 67 | { 68 | while (*str != '\0' && check_separator(*str)) 69 | str++; 70 | if (*str != '\0') 71 | { 72 | strings[i] = ft_word(str); 73 | i++; 74 | } 75 | while (*str && !check_separator(*str)) 76 | str++; 77 | } 78 | strings[i] = 0; 79 | return (strings); 80 | } 81 | 82 | #include 83 | int main(int argc, char **argv) 84 | { 85 | int index; 86 | char **split; 87 | (void) argc; 88 | split = ft_split(argv[1]); 89 | index = 0; 90 | while (split[index]) 91 | { 92 | printf("%s\n", split[index]); 93 | index++; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /EXAM03/11-ft_split/ft_split.c: -------------------------------------------------------------------------------- 1 | #include 2 | int check_separator(char c) 3 | { 4 | if ( c == 10 || c == 9 || c == 32) 5 | return (1); 6 | if (c == 0) 7 | return (1); 8 | return (0); 9 | } 10 | 11 | int count_strings(char *str) 12 | { 13 | int i; 14 | int count; 15 | 16 | count = 0; 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | while (str[i] != '\0' && check_separator(str[i])) 21 | i++; 22 | if (str[i] != '\0') 23 | count++; 24 | while (str[i] != '\0' && !check_separator(str[i])) 25 | i++; 26 | } 27 | return (count); 28 | } 29 | 30 | int ft_strlen_sep(char *str) 31 | { 32 | int i; 33 | 34 | i = 0; 35 | while (str[i] && !check_separator(str[i])) 36 | i++; 37 | return (i); 38 | } 39 | 40 | char *ft_word(char *str) 41 | { 42 | int len_word; 43 | int i; 44 | char *word; 45 | 46 | i = 0; 47 | len_word = ft_strlen_sep(str); 48 | word = (char *)malloc(sizeof(char) * (len_word + 1)); 49 | while (i < len_word) 50 | { 51 | word[i] = str[i]; 52 | i++; 53 | } 54 | word[i] = '\0'; 55 | return (word); 56 | } 57 | 58 | char **ft_split(char *str) 59 | { 60 | char **strings; 61 | int i; 62 | 63 | i = 0; 64 | strings = (char **)malloc(sizeof(char *) 65 | * (count_strings(str) + 1)); 66 | while (*str != '\0') 67 | { 68 | while (*str != '\0' && check_separator(*str)) 69 | str++; 70 | if (*str != '\0') 71 | { 72 | strings[i] = ft_word(str); 73 | i++; 74 | } 75 | while (*str && !check_separator(*str)) 76 | str++; 77 | } 78 | strings[i] = 0; 79 | return (strings); 80 | } 81 | 82 | #include 83 | int main(int argc, char **argv) 84 | { 85 | int index; 86 | char **split; 87 | (void) argc; 88 | split = ft_split(argv[1]); 89 | index = 0; 90 | while (split[index]) 91 | { 92 | printf("%s\n", split[index]); 93 | index++; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /shell00/ex01/testShell00.tar: -------------------------------------------------------------------------------- 1 | testShell00000455 306314 010175 00000000050 14436217327 015111 0ustar00ameziouncandidates000000 000000 111111111111111111111111111111111111111 2 | -------------------------------------------------------------------------------- /EXAM03/13-count_alpha/count_alpha.c: -------------------------------------------------------------------------------- 1 | bool ft_is_uppercase(char c) 2 | { 3 | return (c >= 'A' && c <= 'Z'); 4 | } 5 | 6 | int ft_count_alpha_recursive_count(char *str, char target) 7 | { 8 | int count; 9 | char current; 10 | 11 | count = 0; 12 | while ((current = *str)) 13 | { 14 | if (ft_is_uppercase(current)) 15 | current += CASE_OFFSET; 16 | if (target == current) 17 | count++; 18 | str++; 19 | } 20 | return (count); 21 | } 22 | 23 | void ft_count_alpha_print(int occurences[LETTER_COUNT + 1], 24 | char order[LETTER_COUNT + 1]) 25 | { 26 | int index; 27 | int size; 28 | 29 | size = 0; 30 | while (order[size] != '\0') 31 | size++; 32 | index = 0; 33 | while (index < size) 34 | { 35 | printf("%d%c", occurences[order[index] - 'a'], order[index]); 36 | if (index != size - 1) 37 | printf(", "); 38 | index++; 39 | } 40 | } 41 | 42 | char ft_count_alpha_validate(char c, int occurences[LETTER_COUNT + 1]) 43 | { 44 | if (!ft_is_uppercase(c) && !((c >= 'a' && c <= 'z'))) 45 | return ('\0'); 46 | if (ft_is_uppercase(c)) 47 | c += CASE_OFFSET; 48 | if (occurences[(int)c - 'a'] != NOT_COUNTED_YET) 49 | return ('\0'); 50 | return (c); 51 | } 52 | 53 | void ft_count_alpha(char *str) 54 | { 55 | int index; 56 | int occurences[LETTER_COUNT + 1]; 57 | char occurences_order[LETTER_COUNT + 1]; 58 | char current; 59 | 60 | index = 0; 61 | while (index < LETTER_COUNT + 1) 62 | { 63 | occurences[index] = NOT_COUNTED_YET; 64 | occurences_order[index] = '\0'; 65 | index++; 66 | } 67 | index = 0; 68 | while (*str) 69 | { 70 | current = ft_count_alpha_validate(*str, occurences); 71 | if (current != '\0') 72 | { 73 | occurences[(int)current - 'a'] = ft_count_alpha_recursive_count(str, current); 74 | occurences_order[index] = current; 75 | index++; 76 | } 77 | str++; 78 | } 79 | ft_count_alpha_print(occurences, occurences_order); 80 | } 81 | 82 | int main(int argc, char **argv) 83 | { 84 | if (argc == 2) 85 | ft_count_alpha(argv[1]); 86 | printf("\n"); 87 | } 88 | -------------------------------------------------------------------------------- /C03/ex05/ft_strstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: amezioun +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/10/25 15:45:44 by amezioun #+# #+# */ 9 | /* Updated: 2023/10/25 15:58:07 by amezioun ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | /* 16 | char *ft_strstr(char *str, char *to_find); 17 | int ft_strncmp(char *s1, char *s2, unsigned int n); 18 | unsigned int ft_strlen(char *str); 19 | void ft_putchar(char c); 20 | 21 | int main(void) 22 | { 23 | char haystack[] = "the world is em empty without achraf"; 24 | char needle[] = "emp"; 25 | 26 | ft_strstr(haystack, needle); 27 | } 28 | 29 | char *ft_strstr(char *str, char *to_find) 30 | { 31 | int i; 32 | int k; 33 | 34 | i = 0; 35 | k = 0; 36 | while (str) 37 | { 38 | while (to_find[i]) 39 | { 40 | if (ft_strncmp(str, to_find, ft_strlen(to_find)) == 0) 41 | { 42 | while (str[k]) 43 | { 44 | ft_putchar(str[k]); 45 | k++; 46 | } 47 | } 48 | i++; 49 | } 50 | str++; 51 | } 52 | return (str); 53 | } 54 | 55 | int ft_strncmp(char *s1, char *s2, unsigned int n) 56 | { 57 | unsigned int i; 58 | 59 | i = 0; 60 | while ((s1[i] != '\0' || s2[i] != '\0') && i < n) 61 | { 62 | if (s1[i] != s2[i]) 63 | { 64 | return (s1[i] - s2[i]); 65 | } 66 | i++; 67 | } 68 | return (0); 69 | } 70 | 71 | unsigned int ft_strlen(char *str) 72 | { 73 | int i; 74 | 75 | i = 0; 76 | while (str[i]) 77 | { 78 | i++; 79 | } 80 | return (i); 81 | } 82 | void ft_putchar(char c) 83 | { 84 | write(1, &c, 1); 85 | } 86 | */ 87 | #include 88 | #include 89 | 90 | char *ft_strstr(char *str, char *to_find) 91 | { 92 | int i; 93 | int j; 94 | int k; 95 | 96 | i = 0; 97 | while (to_find[i] != '\0') 98 | i++; 99 | if (i == 0) 100 | return (str); 101 | j = 0; 102 | while (str[j] != '\0') 103 | { 104 | k = 0; 105 | while (str[j + k] == to_find[k]) 106 | { 107 | k++; 108 | if (k == i) 109 | return (&str[j]); 110 | } 111 | j++; 112 | } 113 | return (0); 114 | } 115 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 1337 Med Pool 2023 – My Experience 2 | 3 | Just a brief overview of my *1337 Med Pool experience (2023)*. 4 | 5 | 6 | ### Pool? 7 | 8 | 9 | **pool:** is a unique experience of 28 days filled with **hard work**, **stress**, and **fun moments** that I believe **everybody should give a try**. 10 | Whether you pass it or not, I'm sure you’ll walk away knowing **something new about yourself**. 11 | 12 | During these intense days, you build more than just technical skills you build **memories, and a good friendships**. 13 | 14 | ![Memories](./medpool.jpg) 15 | 16 | --- 17 | 18 | 19 | ## A Few Words of Advice 20 | 21 | A three necessary things that you should know: 22 | 23 | ### 1. Don't Compare Yourself to Others 24 | Focus on your own progress. Everyone learns at a different pace. 25 | Aim to improve **your skills** day after day, that's what really matters. 26 | 27 | ### 2. Respect Your Peers 28 | Avoid conflicts. Getting into fights can lead to **serious trouble**, including being **kicked out** of the piscine. It might even cost you your second chance. 29 | 30 | ### 3. Never Cheat 31 | Cheating will get you **blacklisted** from the school permanently. 32 | No warnings. No second chances. 33 | 34 | --- 35 | ## Finaly 36 | 37 | I won’t tell you everything about the piscine and that’s on purpose. 38 | 39 | Because part of what makes the piscine so special is **discovering it for yourself**. The surprises, the challenges, the late nights, the breakthroughs. they all hit differently when you experience them firsthand. 40 | 41 | So go in with an open mind, a strong heart, and a willingness to learn. 42 | 43 | 44 | --- 45 | ## My Progress 46 | 47 | | Project | Score | 48 | |----------------------|-------| 49 | | [C Piscine C 00](https://github.com/AchrafMez/1337-piscine/tree/main/C00) | 85 | 50 | | [C Piscine C 01](https://github.com/AchrafMez/1337-piscine/tree/main/C01) | 65 | 51 | | [C Piscine C 02](https://github.com/AchrafMez/1337-piscine/tree/main/C02) | 55 | 52 | | [C Piscine C 03](https://github.com/AchrafMez/1337-piscine/tree/main/C03) | 87 | 53 | | [C Piscine C 04](https://github.com/AchrafMez/1337-piscine/tree/main/C04) | 70 | 54 | | [C Piscine C 05](https://github.com/AchrafMez/1337-piscine/tree/main/C05) | 55 | 55 | | [C Piscine C 06](https://github.com/AchrafMez/1337-piscine/tree/main/C06) | 70 | 56 | | [C Piscine C 07](https://github.com/AchrafMez/1337-piscine/tree/main/C07) | 0 | 57 | | [C Piscine Exam 00](https://github.com/AchrafMez/1337-piscine/tree/main/EXAM00) | 40 | 58 | | [C Piscine Exam 01](https://github.com/AchrafMez/1337-piscine/tree/main/EXAM01) | 30 | 59 | | [C Piscine Exam 02](https://github.com/AchrafMez/1337-piscine/tree/main/EXAM02) | 20 | 60 | | [C Piscine Final Exam](https://github.com/AchrafMez/1337-piscine/tree/main/EXAM03) | 48 | 61 | | [C Piscine Shell 00](https://github.com/AchrafMez/1337-piscine/tree/main/shell00) | 100 | 62 | | [C Piscine Shell 01](https://github.com/AchrafMez/1337-piscine/tree/main/shell01) | 70 | 63 | -------------------------------------------------------------------------------- /shell00/ex02/exo2.tar: -------------------------------------------------------------------------------- 1 | test0/000715 306314 010175 00000000000 14436172664 014123 5ustar00ameziouncandidates000000 000000 test1000714 306314 010175 00000000004 14436201610 014023 0ustar00ameziouncandidates000000 000000 123 2 | test2/000504 306314 010175 00000000000 14436210534 014106 5ustar00ameziouncandidates000000 000000 test3000404 306314 010175 00000000001 14436217460 014030 0ustar00ameziouncandidates000000 000000 3 | test4000641 306314 010175 00000000002 14436217364 014040 0ustar00ameziouncandidates000000 000000 1 4 | test5000404 306314 010175 00000000000 14436217460 015015 1test3ustar00ameziouncandidates000000 000000 test6000777 306314 010175 00000000000 14436205600 015022 2test0ustar00ameziouncandidates000000 000000 -------------------------------------------------------------------------------- /EXAM03/14-str-maxlenoc/str_maxlenoc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int ft_str_length(char *str) 7 | { 8 | int length; 9 | 10 | length = 0; 11 | while (str[length]) 12 | length++; 13 | return (length); 14 | } 15 | 16 | void ft_str_write(char *str) 17 | { 18 | while (*str) 19 | write(1, str++, 1); 20 | } 21 | 22 | char *ft_str_n_duplicate(char *str, int n) 23 | { 24 | int index; 25 | char *duplicate; 26 | 27 | if (!(duplicate = (char *)malloc((n + 1) * sizeof(char)))) 28 | return (NULL); 29 | index = 0; 30 | while (str[index] && index < n) 31 | { 32 | duplicate[index] = str[index]; 33 | index++; 34 | } 35 | while (index < n + 1) 36 | { 37 | duplicate[index] = '\0'; 38 | index++; 39 | } 40 | return (duplicate); 41 | } 42 | 43 | int x_cmp_n_size(char *find, char *where, int n) 44 | { 45 | int index; 46 | 47 | index = 0; 48 | while (find[index] == where[index] && find[index] && n--) 49 | index++; 50 | if (find[index] != '\0') 51 | return (0); 52 | return (1); 53 | } 54 | 55 | int ft_compute_score(char *find, char **strs, int strs_size) 56 | { 57 | int index; 58 | int size; 59 | int offset; 60 | int end_offset; 61 | char *str; 62 | int score; 63 | int curr_biggest_score; 64 | int biggest_score; 65 | 66 | index = 0; 67 | biggest_score = -1; 68 | while (index < strs_size) 69 | { 70 | str = strs[index]; 71 | size = ft_str_length(str); 72 | offset = 0; 73 | curr_biggest_score = -1; 74 | while (offset < size) 75 | { 76 | end_offset = size; 77 | while (end_offset > offset) 78 | { 79 | score = x_cmp_n_size(find, str + offset, end_offset - offset + 1); 80 | if (score > curr_biggest_score) 81 | curr_biggest_score += score; 82 | end_offset--; 83 | } 84 | offset++; 85 | } 86 | biggest_score += curr_biggest_score; 87 | index++; 88 | } 89 | return (biggest_score); 90 | } 91 | 92 | void ft_do_on_all_comb(char **strs, int strs_size, char **copies, int *scores) 93 | { 94 | int size; 95 | int offset; 96 | int end_offset; 97 | int jndex; 98 | 99 | size = ft_str_length(strs[0]); 100 | offset = 0; 101 | jndex = 0; 102 | while (offset < size) 103 | { 104 | end_offset = size; 105 | while (end_offset > offset) 106 | { 107 | copies[jndex] = ft_str_n_duplicate(strs[0] + offset, end_offset - offset); 108 | scores[jndex] = ft_compute_score(copies[jndex], strs + 1, strs_size - 1); 109 | end_offset--; 110 | jndex++; 111 | } 112 | offset++; 113 | } 114 | } 115 | 116 | int ft_count_possibility(char *str) 117 | { 118 | int count; 119 | int size; 120 | int offset; 121 | int end_offset; 122 | 123 | count = 0; 124 | size = ft_str_length(str); 125 | offset = 0; 126 | while (offset < size) 127 | { 128 | end_offset = size; 129 | while (end_offset-- > offset) 130 | count++; 131 | offset++; 132 | } 133 | return (count); 134 | } 135 | 136 | void ft_swap_int(int *a, int *b) 137 | { 138 | int c; 139 | 140 | c = *a; 141 | *a = *b; 142 | *b = c; 143 | } 144 | 145 | void ft_swap_str(char **a, char **b) 146 | { 147 | char *c; 148 | 149 | c = *a; 150 | *a = *b; 151 | *b = c; 152 | } 153 | 154 | void bubble_sort(int size, char **copies, int *scores) 155 | { 156 | int index; 157 | int jndex; 158 | bool swapped; 159 | 160 | index = 0; 161 | while (index < size) 162 | { 163 | swapped = false; 164 | jndex = index + 1; 165 | while (jndex < size) 166 | { 167 | if (scores[index] < scores[jndex]) 168 | { 169 | ft_swap_int(&(scores[index]), &(scores[jndex])); 170 | ft_swap_str(&(copies[index]), &(copies[jndex])); 171 | swapped = true; 172 | } 173 | jndex++; 174 | } 175 | index++; 176 | if (!swapped) 177 | break ; 178 | } 179 | } 180 | 181 | bool is_fitting_on_everyone(char *what, char **strs, int size) 182 | { 183 | int index; 184 | char *haystack; 185 | char *needle; 186 | 187 | if (ft_str_length(what) == 0) 188 | return (true); 189 | index = 0; 190 | while (index < size) 191 | { 192 | needle = what; 193 | haystack = strs[index]; 194 | if (ft_str_length(haystack) != 0) 195 | { 196 | while (true) 197 | { 198 | if (*needle == '\0') 199 | break ; 200 | if (*needle == *haystack) 201 | needle++; 202 | else 203 | needle = what; 204 | if (*haystack == '\0') 205 | return (false); 206 | haystack++; 207 | } 208 | } 209 | index++; 210 | } 211 | return (true); 212 | } 213 | 214 | void print_best(int size, char **copies, char **originals, int originals_size, int *scores) 215 | { 216 | int index; 217 | int jndex; 218 | int valid_score; 219 | int validated; 220 | char **final_copies; 221 | int longest; 222 | 223 | index = 0; 224 | jndex = 0; 225 | validated = 0; 226 | valid_score = INT_MAX; 227 | if (!(final_copies = (char **)malloc(size * sizeof(char *)))) 228 | return ; 229 | while (index < size) 230 | { 231 | if (is_fitting_on_everyone(copies[index], originals, originals_size)) 232 | { 233 | if (valid_score == INT_MAX) 234 | valid_score = scores[index]; 235 | if (scores[index] != valid_score) 236 | break ; 237 | final_copies[jndex] = copies[index]; 238 | validated++; 239 | jndex++; 240 | } 241 | index++; 242 | } 243 | if (validated == 0) 244 | return ; 245 | index = 0; 246 | longest = -1; 247 | jndex = -1; 248 | while (index < validated) 249 | { 250 | if (longest < ft_str_length(final_copies[index])) 251 | { 252 | longest = ft_str_length(final_copies[index]); 253 | jndex = index; 254 | } 255 | index++; 256 | } 257 | if (jndex == -1) 258 | return ; 259 | ft_str_write(final_copies[jndex]); 260 | free(final_copies); 261 | } 262 | 263 | void clear_results(int size, char **copies, int *scores) 264 | { 265 | int index; 266 | 267 | index = 0; 268 | while (index < size) 269 | { 270 | free(copies[index]); 271 | index++; 272 | } 273 | free(copies); 274 | free(scores); 275 | } 276 | 277 | void ft_str_maxlenoc(char **strs, int size) 278 | { 279 | int possibilities; 280 | char **copies; 281 | int *scores; 282 | 283 | possibilities = ft_count_possibility(strs[0]); 284 | copies = (char **)malloc(possibilities * sizeof(char *)); 285 | scores = (int *)malloc(possibilities * sizeof(int)); 286 | if (!scores || !copies) 287 | return ; 288 | ft_do_on_all_comb(strs, size, copies, scores); 289 | bubble_sort(possibilities, copies, scores); 290 | print_best(possibilities, copies, strs + 1, size - 1, scores); 291 | clear_results(possibilities, copies, scores); 292 | } 293 | 294 | int main(int argc, char **argv) 295 | { 296 | if (argc > 1) 297 | ft_str_maxlenoc(argv + 1, argc - 1); 298 | write(1, "\n", 1); 299 | } 300 | --------------------------------------------------------------------------------