├── shell00 ├── ex00 │ └── z ├── ex04 │ └── midLS ├── ex05 │ └── git_commit.sh ├── .DS_Store ├── ex06 │ └── git_ignore.sh ├── ex08 │ └── clean ├── ex03 │ └── klist.txt ├── ex07 │ └── b ├── ex01 │ └── testShell00.tar └── ex02 │ └── exo2.tar ├── shell01 ├── ex05 │ └── "\?$*'MaRViN'*$?\" ├── ex06 │ └── skip.sh ├── ex04 │ └── MAC.sh ├── ex01 │ └── print_groups.sh ├── ex03 │ └── count_files.sh ├── .DS_Store └── ex02 │ └── find_sh.sh ├── C01 ├── ex00 │ ├── a.out │ └── ft_ft.c ├── ex01 │ ├── a.out │ └── ft_ultimate_ft.c ├── ex07 │ ├── a.out │ └── ft_rev_int_tab.c ├── ex02 │ ├── .ft_swap.c.swp │ └── ft_swap.c ├── ex03 │ └── ft_div_mod.c ├── ex05 │ └── ft_putstr.c ├── ex04 │ └── ft_ultimate_div_mod.c └── ex06 │ └── ft_strlen.c ├── C02 ├── ex01 │ ├── .DS_Store │ └── ft_strncpy.c ├── ex10 │ ├── .DS_Store │ └── ft_strlcpy.c ├── ex00 │ └── ft_strcpy.c ├── ex07 │ └── ft_strupcase.c ├── ex03 │ └── ft_str_is_numeric.c ├── ex08 │ └── ft_strlowcase.c ├── ex04 │ └── ft_str_is_lowercase.c ├── ex05 │ └── ft_str_is_uppercase.c ├── ex06 │ └── ft_str_is_printable.c ├── ex02 │ └── ft_str_is_alpha.c └── ex09 │ └── ft_strcapitalize.c ├── C03 ├── ex03 │ ├── .DS_Store │ └── ft_strncat.c ├── ex00 │ └── ft_strcmp.c ├── ex01 │ └── ft_strncmp.c ├── ex02 │ └── ft_strcat.c └── ex04 │ └── ft_strstr.c ├── C00 ├── ex00 │ └── ft_putchar.c ├── ex04 │ └── ft_is_negative.c ├── ex03 │ └── ft_print_numbers.c ├── ex01 │ └── ft_print_alphabet.c ├── ex02 │ └── ft_print_reverse_alphabet.c ├── ex07 │ └── ft_putnbr.c ├── ex06 │ └── ft_print_comb2.c └── ex05 │ └── ft_print_comb.c ├── C04 ├── ex01 │ └── ft_putstr.c ├── ex00 │ └── ft_strlen.c ├── ex02 │ └── ft_putnbr.c └── ex03 │ └── ft_atoi.c ├── C05 ├── ex01 │ └── ft_recursive_factorial.c ├── ex04 │ └── ft_fibonacci.c ├── ex03 │ └── ft_recursive_power.c ├── ex06 │ └── ft_is_prime.c ├── ex05 │ └── ft_sqrt.c ├── ex02 │ └── ft_iterative_power.c └── ex00 │ └── ft_iterative_factorial.c ├── C06 ├── ex00 │ └── ft_print_program_name.c ├── ex02 │ └── ft_rev_params.c ├── ex01 │ └── ft_print_params.c └── ex03 │ └── ft_sort_params.c └── README.md /shell00/ex00/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /shell01/ex05/"\?$*'MaRViN'*$?\": -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /shell00/ex04/midLS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -mUtp 3 | -------------------------------------------------------------------------------- /shell01/ex06/skip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l | awk 'NR%2' -------------------------------------------------------------------------------- /shell00/ex05/git_commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git log -5 --pretty=%H 3 | -------------------------------------------------------------------------------- /shell01/ex04/MAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ifconfig -a | grep ether | cut -c 8-24 -------------------------------------------------------------------------------- /shell01/ex01/print_groups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | groups $FT_USER | tr ' ' ',' | tr -d '\n' 3 | -------------------------------------------------------------------------------- /shell01/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f -o -type d | wc -l | tr -d ' ' -------------------------------------------------------------------------------- /C01/ex00/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C01/ex00/a.out -------------------------------------------------------------------------------- /C01/ex01/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C01/ex01/a.out -------------------------------------------------------------------------------- /C01/ex07/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C01/ex07/a.out -------------------------------------------------------------------------------- /shell00/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/shell00/.DS_Store -------------------------------------------------------------------------------- /shell00/ex06/git_ignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git status -s --ignored | grep '!!' | sed 's/!! //' 3 | -------------------------------------------------------------------------------- /shell00/ex08/clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f \( -name '*~' -o -name '#*#' \) -print -delete 3 | -------------------------------------------------------------------------------- /shell01/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/shell01/.DS_Store -------------------------------------------------------------------------------- /shell01/ex02/find_sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f -name '*.sh' | sed 's/.*\///' | sed 's/...$//' -------------------------------------------------------------------------------- /C02/ex01/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C02/ex01/.DS_Store -------------------------------------------------------------------------------- /C02/ex10/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C02/ex10/.DS_Store -------------------------------------------------------------------------------- /C03/ex03/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C03/ex03/.DS_Store -------------------------------------------------------------------------------- /C01/ex02/.ft_swap.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayoub0x1/C-Piscine-june-2021/HEAD/C01/ex02/.ft_swap.c.swp -------------------------------------------------------------------------------- /shell00/ex03/klist.txt: -------------------------------------------------------------------------------- 1 | Credentials cache: API:597EA158-C46F-4F28-9226-87F55BEEEF86 2 | Principal: asoursou@42.FR 3 | 4 | Issued Expires Principal 5 | Jul 1 08:56:05 2019 Jul 8 08:56:05 2019 krbtgt/42.FR@42.FR 6 | Jul 1 09:46:20 2019 Jul 8 08:56:05 2019 host/vgs-fn1.42.fr@42.FR 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /C00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 09:47:19 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/23 10:56:58 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /C01/ex02/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 12:09:23 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:07:18 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_swap(int *a, int *b) 14 | { 15 | int c; 16 | 17 | c = *a; 18 | *a = *b; 19 | *b = c; 20 | } 21 | -------------------------------------------------------------------------------- /C01/ex03/ft_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 12:55:04 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:07:37 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_div_mod(int a, int b, int *div, int *mod) 14 | { 15 | *div = a / b; 16 | *mod = a % b; 17 | } 18 | -------------------------------------------------------------------------------- /C01/ex05/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 14:04:45 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:18:07 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | write(1, str++, 1); 19 | } 20 | -------------------------------------------------------------------------------- /C04/ex01/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 17:43:32 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/01 17:46:21 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | write(1, str++, 1); 19 | } 20 | -------------------------------------------------------------------------------- /C01/ex04/ft_ultimate_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 13:34:50 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:10:30 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_ultimate_div_mod(int *a, int *b) 14 | { 15 | int c; 16 | 17 | c = *a; 18 | *a = c / *b; 19 | *b = c % *b; 20 | } 21 | -------------------------------------------------------------------------------- /C01/ex06/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 14:27:27 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:17:49 by aymoulou ### ########.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]) 21 | i++; 22 | return (i); 23 | } 24 | -------------------------------------------------------------------------------- /C04/ex00/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 17:14:13 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/01 17:18:25 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (*str[i]) 21 | i++; 22 | return (i); 23 | } 24 | -------------------------------------------------------------------------------- /C03/ex00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/03 11:43:32 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/05 11:53:56 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strcmp(char *s1, char *s2) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (s1[i] && s2[i] && s1[i] == s2[i]) 19 | i++; 20 | return (s1[i] - s2[i]); 21 | } 22 | -------------------------------------------------------------------------------- /C05/ex01/ft_recursive_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:13:05 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:19:08 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_recursive_factorial(int nb) 14 | { 15 | if (nb < 0) 16 | return (0); 17 | if (nb == 0 || nb == 1) 18 | return (1); 19 | return (nb * ft_recursive_factorial(nb - 1)); 20 | } 21 | -------------------------------------------------------------------------------- /C05/ex04/ft_fibonacci.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fibonacci.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 10:30:38 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 10:40:01 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_fibonacci(int index) 14 | { 15 | if (index < 0) 16 | return (-1); 17 | if (index < 2) 18 | return (index); 19 | return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2)); 20 | } 21 | -------------------------------------------------------------------------------- /C05/ex03/ft_recursive_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:45:33 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:49:17 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_recursive_power(int nb, int power) 14 | { 15 | if (power < 0) 16 | return (0); 17 | else if (power < 1) 18 | return (1); 19 | else 20 | return (nb * ft_recursive_power(nb, power - 1)); 21 | } 22 | -------------------------------------------------------------------------------- /C01/ex00/ft_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 11:59:44 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:06:28 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | void ft_ft(int nbr) 16 | { 17 | nbr = 42; 18 | } 19 | 20 | int main() 21 | { 22 | int i; 23 | int* pt1; 24 | i = 0; 25 | pt1 = &i; 26 | ft_ft(i); 27 | printf("%d", i); 28 | } 29 | -------------------------------------------------------------------------------- /C05/ex06/ft_is_prime.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_prime.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 11:07:55 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 11:27:32 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_is_prime(int nb) 14 | { 15 | int i; 16 | 17 | i = 2; 18 | if (nb <= 1) 19 | return (0); 20 | while (i <= nb / i) 21 | { 22 | if (nb % i == 0) 23 | return (0); 24 | i++; 25 | } 26 | return (1); 27 | } 28 | -------------------------------------------------------------------------------- /C00/ex04/ft_is_negative.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_negative.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 14:25:17 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:17:59 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_is_negative(int n) 21 | 22 | { 23 | if (n >= 0) 24 | ft_putchar('P'); 25 | else 26 | ft_putchar('N'); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex00/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/26 18:58:15 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:36:31 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strcpy(char *dest, char *src) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (src[i]) 21 | { 22 | dest[i] = src[i]; 23 | i++; 24 | } 25 | dest[i] = src[i]; 26 | return (dest); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex07/ft_strupcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strupcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 14:12:44 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:39:39 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strupcase(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | if (str[i] >= 'a' && str[i] <= 'z') 23 | str[i] -= 32; 24 | i++; 25 | } 26 | return (str); 27 | } 28 | -------------------------------------------------------------------------------- /C05/ex05/ft_sqrt.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sqrt.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 10:47:19 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 11:24:06 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_sqrt(int nb) 14 | { 15 | int i; 16 | int sq; 17 | 18 | i = 1; 19 | sq = 1; 20 | if (nb == 0) 21 | return (0); 22 | while (i * i < nb) 23 | i++; 24 | if ((nb % i) == 0) 25 | return (i); 26 | else 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /C02/ex03/ft_str_is_numeric.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_numeric.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 11:57:32 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:38:07 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_numeric(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | if (!(str[i] >= '0' && str[i] <= '9')) 23 | return (0); 24 | i++; 25 | } 26 | return (1); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex08/ft_strlowcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlowcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 15:03:25 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:40:11 by aymoulou ### ########.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]) 21 | { 22 | if (str[i] >= 'A' && str[i] <= 'Z') 23 | str[i] += 32; 24 | i++; 25 | } 26 | return (str); 27 | } 28 | -------------------------------------------------------------------------------- /C03/ex01/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/29 10:08:35 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/05 11:40:02 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strncmp(char *s1, char *s2, unsigned int n) 14 | { 15 | unsigned int i; 16 | 17 | if (n == 0) 18 | return (0); 19 | i = 0; 20 | while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0' && i < n - 1) 21 | i++; 22 | return (s1[i] - s2[i]); 23 | } 24 | -------------------------------------------------------------------------------- /C02/ex04/ft_str_is_lowercase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_lowercase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 12:46:50 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:38:30 by aymoulou ### ########.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]) 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: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 13:35:56 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:38:52 by aymoulou ### ########.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]) 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: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 13:51:57 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:39:16 by aymoulou ### ########.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]) 21 | { 22 | if (!(str[i] >= 32 && str[i] <= 126)) 23 | { 24 | return (0); 25 | } 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C00/ex03/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_numbers.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 11:56:16 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:17:27 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_print_numbers(void) 21 | { 22 | char number; 23 | 24 | number = '0'; 25 | while (number <= '9') 26 | { 27 | ft_putchar(number); 28 | number++; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /C00/ex01/ft_print_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 10:59:17 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:13:26 by aymoulou ### ########.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_alphabet(void) 21 | { 22 | char letter; 23 | 24 | letter = 'a'; 25 | while (letter <= 'z') 26 | { 27 | ft_putchar(letter); 28 | letter++; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /C03/ex02/ft_strcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/29 11:21:57 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/04 20:08:59 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strcat(char *dest, char *src) 14 | { 15 | unsigned int i; 16 | unsigned int j; 17 | 18 | i = 0; 19 | j = 0; 20 | while (dest[i]) 21 | i++; 22 | while (src[j]) 23 | { 24 | dest[i + j] = src[j]; 25 | j++; 26 | } 27 | dest[i + j] = '\0'; 28 | return (dest); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex02/ft_str_is_alpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_alpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 10:31:55 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 12:05:04 by aymoulou ### ########.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]) 21 | { 22 | if (!(str[i] >= 'a' && str[i] <= 'z') 23 | && !(str[i] >= 'A' && str[i] <= 'Z')) 24 | return (0); 25 | i++; 26 | } 27 | return (1); 28 | } 29 | -------------------------------------------------------------------------------- /C06/ex00/ft_print_program_name.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_program_name.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 08:55:57 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:10:34 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | { 19 | write(1, str, 1); 20 | str++; 21 | } 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void)argc; 27 | ft_putstr(argv[0]); 28 | ft_putstr("\n"); 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /C00/ex02/ft_print_reverse_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_reverse_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 11:47:14 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:15:17 by aymoulou ### ########.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_reverse_alphabet(void) 21 | { 22 | char letter; 23 | 24 | letter = 'z'; 25 | while (letter >= 'a') 26 | { 27 | ft_putchar(letter); 28 | letter--; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /C05/ex02/ft_iterative_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:21:51 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:44:40 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_iterative_power(int nb, int power) 14 | { 15 | int i; 16 | int nbr; 17 | 18 | i = 1; 19 | nbr = nb; 20 | if (power == 0) 21 | return (1); 22 | if (power < 0) 23 | return (0); 24 | while (i < power) 25 | { 26 | nb = nb * nbr; 27 | i++; 28 | } 29 | return (nb); 30 | } 31 | -------------------------------------------------------------------------------- /C02/ex01/ft_strncpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 09:10:04 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 16:35:03 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strncpy(char *dest, char *src, unsigned int n) 16 | { 17 | unsigned int i; 18 | 19 | i = 0; 20 | while (src[i] && i < n) 21 | { 22 | dest[i] = src[i]; 23 | i++; 24 | } 25 | while (i < n) 26 | { 27 | dest[i] = '\0'; 28 | i++; 29 | } 30 | return (dest); 31 | } 32 | -------------------------------------------------------------------------------- /C03/ex03/ft_strncat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/30 09:44:05 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/04 20:33:38 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strncat(char *dest, char *src, unsigned int nb) 14 | { 15 | unsigned int i; 16 | unsigned int j; 17 | 18 | i = 0; 19 | j = 0; 20 | while (dest[i]) 21 | i++; 22 | while (src[j] && j < nb) 23 | { 24 | dest[i + j] = src[j]; 25 | j++; 26 | } 27 | dest[i + j] = '\0'; 28 | return (dest); 29 | } 30 | -------------------------------------------------------------------------------- /C06/ex02/ft_rev_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rev_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:21:51 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:44:40 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | { 19 | write(1, str, 1); 20 | str++; 21 | } 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | while (argc > 1) 27 | { 28 | ft_putstr(argv[argc - 1]); 29 | write(1, "\n", 1); 30 | argc--; 31 | } 32 | return (0); 33 | -------------------------------------------------------------------------------- /C06/ex01/ft_print_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:13:05 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:19:08 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | { 19 | write(1, str, 1); 20 | str++; 21 | } 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | int i; 27 | 28 | i = 1; 29 | while (i < argc) 30 | { 31 | ft_putstr(argv[i]); 32 | write(1, "\n", 1); 33 | i++; 34 | } 35 | return (0); 36 | } 37 | -------------------------------------------------------------------------------- /C03/ex04/ft_strstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/29 11:54:16 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/05 09:57:20 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strstr(char *str, char *to_find) 14 | { 15 | int i; 16 | int j; 17 | 18 | i = 0; 19 | if (to_find[i] == '\0') 20 | return (str); 21 | while (str[i] != '\0') 22 | { 23 | j = 0; 24 | while (str[i + j] == to_find[j]) 25 | { 26 | j++; 27 | if (to_find[j] == '\0') 28 | return (&str[i]); 29 | } 30 | i++; 31 | } 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /C00/ex07/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 17:08:34 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:34:49 by aymoulou ### ########.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 | ft_putchar('-'); 28 | n = -n; 29 | } 30 | if (n > 9) 31 | { 32 | ft_putnbr(n / 10); 33 | ft_putnbr(n % 10); 34 | } 35 | else 36 | { 37 | ft_putchar(n + '0'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /C04/ex02/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 17:47:21 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/04 08:49:53 by aymoulou ### ########.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 | ft_putchar('-'); 28 | n = -n; 29 | } 30 | if (n > 9) 31 | { 32 | ft_putnbr(n / 10); 33 | ft_putnbr(n % 10); 34 | } 35 | else 36 | { 37 | ft_putchar(n + '0'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Piscine-june-2021 2 | Here you can find all the projects that I validated during my Piscine at 1337 School. 3 | 4 | This repo includes my work done during the 4 weeks piscine of 1337 school (part of 42 network), thanks to my efforts and my work during it I got accepted in the school after finishing 8 projects(Shell projects and from C00 to C06). According to my longtime, I worked an average of 14 hours a day by counting breaks and meals so about 12 hours of work on average. 5 | 6 | This experience is really great and I invite anyone who is interested in programming, even if you do not want to integrate the school, to do this intensive month. It's 1 month of intensive learning but also good times ... 7 | 8 | ## Here are my notes: 9 | 10 | 11 | 12 | 13 | # Here is my piscine state: 14 | [![aymoulou's 42 stats](https://badge42.vercel.app/api/v2/cl1kxonbk023209jmqkb8mbrn/stats?cursusId=9&coalitionId=piscine)](https://github.com/ayoub0x1/Piscine-june-2021/blob/master/README.md) 15 | 16 | Warning :warning: : If you are a pisciner, do not copy/paste my code, it will be a cheat and you will directly get a -42/100. 17 | -------------------------------------------------------------------------------- /C05/ex00/ft_iterative_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 08:55:57 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:10:34 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | # include 14 | 15 | int ft_iterative_factorial(int nb) 16 | { 17 | int result; 18 | int i; 19 | 20 | i = 1; 21 | result = 1; 22 | if ((nb <= 0) || (nb > 12)) 23 | return (0); 24 | if (nb == 1) 25 | return (1); 26 | while (i <= nb) 27 | { 28 | result = i * result; 29 | i++; 30 | } 31 | return (result); 32 | } 33 | 34 | 35 | int main() 36 | { 37 | int i = 0; 38 | i = ft_iterative_factorial(7); 39 | printf("%d\n", i); 40 | } -------------------------------------------------------------------------------- /C02/ex09/ft_strcapitalize.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcapitalize.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/27 19:00:34 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 08:40:27 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strcapitalize(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | if (!((str[i - 1] >= 'a' && str[i - 1] <= 'z') 23 | || (str[i - 1] >= 'A' && str[i - 1] <= 'Z') 24 | || (str[i - 1] >= '0' && str[i - 1] <= '9'))) 25 | { 26 | if (str[i] >= 'a' && str[i] <= 'z') 27 | str[i] -= 32; 28 | } 29 | else if (str[i] >= 'A' && str[i] <= 'Z') 30 | str[i] += 32; 31 | i++; 32 | } 33 | return (str); 34 | } 35 | -------------------------------------------------------------------------------- /C04/ex03/ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/03 16:21:32 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/04 09:40:02 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_atoi(char *str) 14 | { 15 | int i; 16 | int sign; 17 | int nbr; 18 | 19 | i = 0; 20 | sign = 1; 21 | nbr = 0; 22 | if (!str[i]) 23 | return (0); 24 | while (str[i] == '\t' || str[i] == '\v' || str[i] == '\n' 25 | || str[i] == '\r' || str[i] == '\f' || str[i] == ' ') 26 | i++; 27 | while (str[i] == '-' || str[i] == '+') 28 | if (str[i++] == '-') 29 | sign *= (-1); 30 | while (str[i] >= '0' && str[i] <= '9') 31 | nbr = (nbr * 10) + (str[i++] - '0'); 32 | return (nbr * sign); 33 | } 34 | -------------------------------------------------------------------------------- /C01/ex01/ft_ultimate_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/24 11:57:17 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:06:46 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_ultimate_ft(int *********nbr) 16 | { 17 | *********nbr = 42; 18 | } 19 | 20 | int main() 21 | { 22 | int i; 23 | 24 | i = 1337; 25 | 26 | int *ptr1 = &i; 27 | int **ptr2 = &ptr1; 28 | int ***ptr3 = &ptr2; 29 | int ****ptr4 = &ptr3; 30 | int *****ptr5 = &ptr4; 31 | int ******ptr6 = &ptr5; 32 | int *******ptr7 = &ptr6; 33 | int ********ptr8 = &ptr7; 34 | int *********ptr9 = &ptr8; 35 | 36 | ft_ultimate_ft(ptr9); 37 | printf("%d", *********ptr9); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /C01/ex07/ft_rev_int_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rev_int_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/01 14:32:58 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/03 10:10:06 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_rev_int_tab(int *tab, int size) 16 | { 17 | int i; 18 | int len; 19 | int swap; 20 | 21 | i = 0; 22 | len = size - 1; 23 | while (i < (size / 2)) 24 | { 25 | swap = tab[i]; 26 | tab[i] = tab[len]; 27 | tab[len] = swap; 28 | i++; 29 | len--; 30 | } 31 | } 32 | 33 | int main() 34 | { 35 | int i; 36 | int tab[8] = {1, 2, 3, 4, 5, 6, 7, 8}; 37 | 38 | //ft_rev_int_tab(tab, 8); 39 | while (i < 8) 40 | { 41 | printf("%d\n", tab[i]); 42 | i++; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /C00/ex06/ft_print_comb2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 20:09:36 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:35:37 by aymoulou ### ########.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 i; 23 | int j; 24 | 25 | i = 0; 26 | while (i <= 98) 27 | { 28 | j = i + 1; 29 | while (j <= 99) 30 | { 31 | ft_putchar(i / 10 + 48); 32 | ft_putchar(i % 10 + 48); 33 | ft_putchar(' '); 34 | ft_putchar(j / 10 + 48); 35 | ft_putchar(j % 10 + 48); 36 | if (i != 98) 37 | { 38 | ft_putchar(','); 39 | ft_putchar(' '); 40 | } 41 | j++; 42 | } 43 | i++; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /C00/ex05/ft_print_comb.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/23 17:20:31 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/24 09:25:00 by aymoulou ### ########.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 tab[3]; 23 | 24 | tab[0] = '/'; 25 | while (++tab[0] <= '7') 26 | { 27 | tab[1] = tab[0]; 28 | while (++tab[1] <= '8') 29 | { 30 | tab[2] = tab[1]; 31 | while (++tab[2] <= '9') 32 | { 33 | ft_putchar(tab[0]); 34 | ft_putchar(tab[1]); 35 | ft_putchar(tab[2]); 36 | if (tab[0] != '7') 37 | { 38 | ft_putchar(','); 39 | ft_putchar(' '); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /C02/ex10/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/06/28 12:25:27 by aymoulou #+# #+# */ 9 | /* Updated: 2021/06/28 16:35:00 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | unsigned int ft_strlen(char *str) 16 | { 17 | unsigned int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | i++; 22 | return (i); 23 | } 24 | 25 | char *ft_strncpy(char *dest, char *src, unsigned int n) 26 | { 27 | unsigned int i; 28 | 29 | i = 0; 30 | while (src[i] && i < n) 31 | { 32 | dest[i] = src[i]; 33 | i++; 34 | } 35 | while (i < n) 36 | { 37 | dest[i] = '\0'; 38 | i++; 39 | } 40 | return (dest); 41 | } 42 | 43 | unsigned int ft_strlcpy(char *dest, char src, unsigned int size) 44 | { 45 | ft_strncpy(dest, src, size); 46 | return (ft_strlen(src)); 47 | } 48 | -------------------------------------------------------------------------------- /C06/ex03/ft_sort_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sort_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aymoulou +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/07/11 09:45:33 by aymoulou #+# #+# */ 9 | /* Updated: 2021/07/11 09:49:17 by aymoulou ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | while (*str) 18 | { 19 | write(1, str, 1); 20 | str++; 21 | } 22 | } 23 | 24 | int ft_strcmp(char *s1, char *s2) 25 | { 26 | int i; 27 | 28 | i = 0; 29 | while (s1[i]) 30 | { 31 | if (s1[i] != s2[i]) 32 | { 33 | return (s1[i] - s2[i]); 34 | } 35 | i++; 36 | } 37 | if (s2[i] == '\0') 38 | return (0); 39 | else 40 | return (-s2[i]); 41 | } 42 | 43 | int main(int argc, char **argv) 44 | { 45 | int i; 46 | int j; 47 | char *tmp; 48 | 49 | i = 0; 50 | while (++i < argc) 51 | { 52 | j = i; 53 | while (++j < argc) 54 | { 55 | if (ft_strcmp(argv[i], argv[j]) > 0) 56 | { 57 | tmp = argv[i]; 58 | argv[i] = argv[j]; 59 | argv[j] = tmp; 60 | } 61 | } 62 | } 63 | i = 0; 64 | while (++i < argc) 65 | { 66 | ft_putstr(argv[i]); 67 | write(1, "\n", 1); 68 | } 69 | return (0); 70 | } 71 | -------------------------------------------------------------------------------- /shell00/ex01/testShell00.tar: -------------------------------------------------------------------------------- 1 | testShell00000455 106605 010321 00000000050 13474570450 014626 0ustar00asoursou2019_paris000000 000000 000000000000000000000000000000000000000 2 | -------------------------------------------------------------------------------- /shell00/ex02/exo2.tar: -------------------------------------------------------------------------------- 1 | test0/000715 106605 010321 00000000000 13474544044 013634 5ustar00asoursou2019_paris000000 000000 test1000714 106605 010321 00000000004 13474552770 013561 0ustar00asoursou2019_paris000000 000000 000 2 | test2/000504 106605 010321 00000000000 13474561714 013635 5ustar00asoursou2019_paris000000 000000 test3000404 106605 010321 00000000001 13474570640 013550 0ustar00asoursou2019_paris000000 000000 3 | test4000641 106605 010321 00000000002 13474570544 013560 0ustar00asoursou2019_paris000000 000000 0 4 | test5000404 106605 010321 00000000000 13474570640 014535 1test3ustar00asoursou2019_paris000000 000000 test6000755 106605 010321 00000000000 13474556760 014554 2test0ustar00asoursou2019_paris000000 000000 --------------------------------------------------------------------------------