diff --git a/C08/ex00/ft.h b/C08/ex00/ft.h new file mode 100644 index 0000000..5f96d69 --- /dev/null +++ b/C08/ex00/ft.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/03 11:02:39 by ajoly #+# #+# */ +/* Updated: 2022/08/04 09:32:35 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_H +# define FT_H + +void ft_putchar(char c); +void ft_swap(int *a, int *b); +void ft_putstr(char *str); +int ft_strlen(char *str); +int ft_strcmp(char *s1, char *s2); + +#endif \ No newline at end of file diff --git a/C08/ex01/ft_boolean.h b/C08/ex01/ft_boolean.h new file mode 100644 index 0000000..294ee8e --- /dev/null +++ b/C08/ex01/ft_boolean.h @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_boolean.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/04 09:35:42 by ajoly #+# #+# */ +/* Updated: 2022/08/04 21:15:45 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_BOOLEAN_H +# define FT_BOOLEAN_H + +# include +# define EVEN(x) x % 2 == 0 +# define EVEN_MSG "I have an even number of arguments.\n" +# define ODD_MSG "I have an odd number of arguments.\n" +# define TRUE 1 +# define FALSE 0 +# define SUCCESS 0 + +typedef int t_bool; + +#endif \ No newline at end of file diff --git a/C08/ex02/ft_abs.h b/C08/ex02/ft_abs.h new file mode 100644 index 0000000..1b03c03 --- /dev/null +++ b/C08/ex02/ft_abs.h @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_abs.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/04 10:03:57 by ajoly #+# #+# */ +/* Updated: 2022/08/04 10:38:23 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_ABS_H +# define FT_ABS_H + +# define ABS(x) (x > 0) ? x : -x + +#endif diff --git a/C08/ex03/ft_point.h b/C08/ex03/ft_point.h new file mode 100644 index 0000000..6f57306 --- /dev/null +++ b/C08/ex03/ft_point.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_point.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/04 10:40:55 by ajoly #+# #+# */ +/* Updated: 2022/08/04 10:47:01 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_POINT_H +# define FT_POINT_H + +typedef struct s_point +{ + int x; + int y; +} t_point; + +#endif diff --git a/C08/ex04/ft_strs_to_tab.c b/C08/ex04/ft_strs_to_tab.c new file mode 100644 index 0000000..61459ac --- /dev/null +++ b/C08/ex04/ft_strs_to_tab.c @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strs_to_tab.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/04 10:52:25 by ajoly #+# #+# */ +/* Updated: 2022/08/04 21:46:09 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "ft_stock_str.h" + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} + +char *ft_strdup(char *src) +{ + int i; + char *dest; + + i = 0; + while (src[i]) + i++; + dest = malloc(i + 1); + i = 0; + while (src[i]) + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +} + +struct s_stock_str *ft_strs_to_tab(int ac, char **av) +{ + t_stock_str *tab; + int i; + + tab = malloc(sizeof(t_stock_str) * (ac + 1)); + if (tab == NULL) + return (NULL); + i = 0; + while (i < ac) + { + tab[i].str = av[i]; + tab[i].copy = ft_strdup(tab[i].str); + tab[i].size = ft_strlen(av[i]); + i++; + } + tab[i].str = 0; + tab[i].size = 0; + tab[i].copy = 0; + return (tab); +} diff --git a/ended/C00/ex00/ft_putchar.c b/ended/C00/ex00/ft_putchar.c new file mode 100644 index 0000000..9048a7b --- /dev/null +++ b/ended/C00/ex00/ft_putchar.c @@ -0,0 +1,7 @@ +#include +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/ended/C00/ex01/ft_print_alphabet.c b/ended/C00/ex01/ft_print_alphabet.c new file mode 100644 index 0000000..57593bb --- /dev/null +++ b/ended/C00/ex01/ft_print_alphabet.c @@ -0,0 +1,14 @@ +#include +#include + +void ft_print_alphabet(void) +{ + char ch; + + ch = 'a'; + while (ch <= 'z') + { + write(1, &ch, 1); + ch++; + } +} diff --git a/ended/C00/ex02/ft_print_reverse_alphabet.c b/ended/C00/ex02/ft_print_reverse_alphabet.c new file mode 100644 index 0000000..320c1ec --- /dev/null +++ b/ended/C00/ex02/ft_print_reverse_alphabet.c @@ -0,0 +1,14 @@ +#include +#include + +void ft_print_reverse_alphabet(void) +{ + char ch; + + ch = 'z'; + while (ch >= 'a') + { + write(1, &ch, 1); + ch--; + } +} diff --git a/ended/C00/ex03/ft_print_numbers.c b/ended/C00/ex03/ft_print_numbers.c new file mode 100644 index 0000000..13fae84 --- /dev/null +++ b/ended/C00/ex03/ft_print_numbers.c @@ -0,0 +1,14 @@ +#include +#include + +void ft_print_numbers(void) +{ + char n; + + n = '0'; + while (n <= '9') + { + write(1, &n, 1); + n++; + } +} diff --git a/ended/C00/ex04/ft_is_negative.c b/ended/C00/ex04/ft_is_negative.c new file mode 100644 index 0000000..2138042 --- /dev/null +++ b/ended/C00/ex04/ft_is_negative.c @@ -0,0 +1,14 @@ +#include +#include + +void ft_is_negative(int n) +{ + if (n < 0) + { + write(1, "N", 1); + } + else + { + write(1, "P", 1); + } +} diff --git a/ended/C00/ex05/ft_print_comb.c b/ended/C00/ex05/ft_print_comb.c new file mode 100644 index 0000000..a114f9a --- /dev/null +++ b/ended/C00/ex05/ft_print_comb.c @@ -0,0 +1,37 @@ +#include +#include + +void ft_print_nb(char a, char b, char c) +{ + write(1, &a, 1); + write(1, &b, 1); + write(1, &c, 1); +} + +void ft_print_comb(void) +{ + char a; + char b; + char c; + + a = '0'; + while (a <= '7') + { + b = a + 1; + while (b <= '8') + { + c = b + 1; + while (c <= '9') + { + ft_print_nb(a, b, c); + if (a != '7') + { + write(1, ", ", 2); + } + c++; + } + b++; + } + a++; + } +} diff --git a/ended/C00/ex06/ft_print_comb2.c b/ended/C00/ex06/ft_print_comb2.c new file mode 100644 index 0000000..86cf98e --- /dev/null +++ b/ended/C00/ex06/ft_print_comb2.c @@ -0,0 +1,57 @@ +#include +#include + +void convert_nb(char nb1, char nb1_10, char nb2, char nb2_10) +{ + char r_nb1; + char r_nb1_10; + char r_nb2; + char r_nb2_10; + + r_nb1 = nb1 + 48; + r_nb1_10 = nb1_10 + 48; + r_nb2 = nb2 + 48; + r_nb2_10 = nb2_10 + 48; + write(1, &r_nb2_10, 1); + write(1, &r_nb2, 1); + write(1, " ", 1); + write(1, &r_nb1_10, 1); + write(1, &r_nb1, 1); +} + +void get_nb(char a, char b) +{ + char nb1; + char nb2; + char nb1_10; + char nb2_10; + + nb1 = a % 10; + nb2 = b % 10; + nb1_10 = a / 10; + nb2_10 = b / 10; + convert_nb(nb1, nb1_10, nb2, nb2_10); +} + +void ft_print_comb2(void) +{ + char nb1; + char nb2; + + nb1 = 0; + nb2 = 0; + while (nb2 <= 98) + { + nb1 = nb2 + 1; + while (nb1 <= 99) + { + get_nb(nb1, nb2); + nb1++; + if (nb2 < 98 || nb1 < 99) + { + write(1, ", ", 2); + } + } + nb2++; + } +} diff --git a/ended/C01/ex00/ft_ft.c b/ended/C01/ex00/ft_ft.c new file mode 100644 index 0000000..eb701f8 --- /dev/null +++ b/ended/C01/ex00/ft_ft.c @@ -0,0 +1,6 @@ +#include + +void ft_ft(int *nbr) +{ + *nbr = 42; +} diff --git a/ended/C01/ex01/ft_ultimate_ft.c b/ended/C01/ex01/ft_ultimate_ft.c new file mode 100644 index 0000000..469f2d3 --- /dev/null +++ b/ended/C01/ex01/ft_ultimate_ft.c @@ -0,0 +1,6 @@ +#include + +void ft_ultimate_ft(int *********nbr) +{ + *********nbr = 42; +} diff --git a/ended/C01/ex02/ft_swap.c b/ended/C01/ex02/ft_swap.c new file mode 100644 index 0000000..ee0bda1 --- /dev/null +++ b/ended/C01/ex02/ft_swap.c @@ -0,0 +1,10 @@ +#include + +void ft_swap(int *a, int *b) +{ + int f; + + f = *a; + *a = *b; + *b = f; +} diff --git a/ended/C01/ex03/ft_div_mod.c b/ended/C01/ex03/ft_div_mod.c new file mode 100644 index 0000000..54eabe5 --- /dev/null +++ b/ended/C01/ex03/ft_div_mod.c @@ -0,0 +1,7 @@ +#include + +void ft_div_mod(int a, int b, int *div, int *mod) +{ + *div = a / b; + *mod = a % b; +} diff --git a/ended/C01/ex04/ft_ultimate_div_mod.c b/ended/C01/ex04/ft_ultimate_div_mod.c new file mode 100644 index 0000000..bc7bcf6 --- /dev/null +++ b/ended/C01/ex04/ft_ultimate_div_mod.c @@ -0,0 +1,12 @@ +#include + +void ft_ultimate_div_mod(int *a, int *b) +{ + int f; + int g; + + f = *a; + g = *b; + *a = f / g; + *b = f % g; +} diff --git a/ended/C01/ex05/ft_putstr.c b/ended/C01/ex05/ft_putstr.c new file mode 100644 index 0000000..eeaa8de --- /dev/null +++ b/ended/C01/ex05/ft_putstr.c @@ -0,0 +1,13 @@ +#include + +void ft_putstr(char *str) +{ + int i; + + i = 0; + while (str[i]) + { + write(1, &str[i], 1); + i++; + } +} diff --git a/ended/C01/ex06/ft_strlen.c b/ended/C01/ex06/ft_strlen.c new file mode 100644 index 0000000..2a98ef7 --- /dev/null +++ b/ended/C01/ex06/ft_strlen.c @@ -0,0 +1,11 @@ +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} diff --git a/ended/C02-corr/ex00/ft_strcpy.c b/ended/C02-corr/ex00/ft_strcpy.c new file mode 100644 index 0000000..7312de7 --- /dev/null +++ b/ended/C02-corr/ex00/ft_strcpy.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + char ff[254] = ""; + + ft_strcpy(ff, "ffff"); + printf("%s", ff); +} diff --git a/ended/C02-corr/ex01/ft_strncpy.c b/ended/C02-corr/ex01/ft_strncpy.c new file mode 100644 index 0000000..9820ddd --- /dev/null +++ b/ended/C02-corr/ex01/ft_strncpy.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + char ff[254] = ""; + + ft_strncpy(ff, "ffffffffff", 4); + printf("%s", ff); +} diff --git a/ended/C02-corr/ex02/ft_str_is_alpha.c b/ended/C02-corr/ex02/ft_str_is_alpha.c new file mode 100644 index 0000000..aa65934 --- /dev/null +++ b/ended/C02-corr/ex02/ft_str_is_alpha.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + int result; + + result = ft_str_is_alpha("adfec"); + printf("%d", result); +} diff --git a/ended/C02-corr/ex03/ft_str_is_numeric.c b/ended/C02-corr/ex03/ft_str_is_numeric.c new file mode 100644 index 0000000..50cbe08 --- /dev/null +++ b/ended/C02-corr/ex03/ft_str_is_numeric.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + int result; + + result = ft_str_is_numeric("1155"); + printf("%d", result); +} diff --git a/ended/C02-corr/ex04/ft_str_is_lowercase.c b/ended/C02-corr/ex04/ft_str_is_lowercase.c new file mode 100644 index 0000000..1c89680 --- /dev/null +++ b/ended/C02-corr/ex04/ft_str_is_lowercase.c @@ -0,0 +1,7 @@ +int main(void) +{ + int result; + + result = ft_str_is_lowercase("adfAec"); + printf("%d", result); +} diff --git a/ended/C02-corr/ex05/ft_str_is_uppercase.c b/ended/C02-corr/ex05/ft_str_is_uppercase.c new file mode 100644 index 0000000..b39b449 --- /dev/null +++ b/ended/C02-corr/ex05/ft_str_is_uppercase.c @@ -0,0 +1,7 @@ +int main(void) +{ + int result; + + result = ft_str_is_uppercase("adfAec"); + printf("%d", result); +} diff --git a/ended/C02-corr/ex06/ft_str_is_printable.c b/ended/C02-corr/ex06/ft_str_is_printable.c new file mode 100644 index 0000000..21fe5c1 --- /dev/null +++ b/ended/C02-corr/ex06/ft_str_is_printable.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + int result; + + result = ft_str_is_printable("adfAec-- "); + printf("%d", result); +} diff --git a/ended/C02-corr/ex07/ft_strupcase.c b/ended/C02-corr/ex07/ft_strupcase.c new file mode 100644 index 0000000..4268dca --- /dev/null +++ b/ended/C02-corr/ex07/ft_strupcase.c @@ -0,0 +1,5 @@ +int main(void) +{ + char str[] = "fFff"; + printf("%s", ft_strupcase(str)); +} diff --git a/ended/C02-corr/ex08/ft_strlowcase.c b/ended/C02-corr/ex08/ft_strlowcase.c new file mode 100644 index 0000000..93188f7 --- /dev/null +++ b/ended/C02-corr/ex08/ft_strlowcase.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + char str[] = "fFffA"; + printf("%s", ft_strlowcase(str)); +} diff --git a/ended/C02-corr/ex09/ft_strcapitalize.c b/ended/C02-corr/ex09/ft_strcapitalize.c new file mode 100644 index 0000000..2365fc4 --- /dev/null +++ b/ended/C02-corr/ex09/ft_strcapitalize.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + char str[250] = "salut, comment tu vas ? 42mots quarante-deux; cinqUante+et+un"; + printf("%s", ft_strcapitalize(str)); +} diff --git a/ended/C02-corr/ex10/ft_strlcpy.c b/ended/C02-corr/ex10/ft_strlcpy.c new file mode 100644 index 0000000..0f87f37 --- /dev/null +++ b/ended/C02-corr/ex10/ft_strlcpy.c @@ -0,0 +1,8 @@ +#include +int main(void) +{ + char ff[220]; + + ft_strlcpy(ff, "ffffff", 4); + printf("%s", ff); +} diff --git a/ended/C02/ex00/ft_strcpy.c b/ended/C02/ex00/ft_strcpy.c new file mode 100644 index 0000000..0b81be4 --- /dev/null +++ b/ended/C02/ex00/ft_strcpy.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 13:14:34 by ajoly #+# #+# */ +/* Updated: 2022/07/19 13:14:45 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcpy(char *dest, char *src) +{ + int i; + + i = 0; + while (src[i] != '\0') + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +} diff --git a/ended/C02/ex01/ft_strncpy.c b/ended/C02/ex01/ft_strncpy.c new file mode 100644 index 0000000..e484733 --- /dev/null +++ b/ended/C02/ex01/ft_strncpy.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 13:15:09 by ajoly #+# #+# */ +/* Updated: 2022/07/19 13:15:13 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strncpy(char *dest, char *src, unsigned int n) +{ + unsigned int i; + + i = 0; + while (i < n && src[i] != '\0') + { + dest[i] = src[i]; + i++; + } + while (i < n) + { + dest[i] = '\0'; + i++; + } + return (dest); +} diff --git a/ended/C02/ex02/ft_str_is_alpha.c b/ended/C02/ex02/ft_str_is_alpha.c new file mode 100644 index 0000000..b18cca9 --- /dev/null +++ b/ended/C02/ex02/ft_str_is_alpha.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_alpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 13:26:15 by ajoly #+# #+# */ +/* Updated: 2022/07/19 13:26:21 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_alpha(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0' ) + { + if (str[i] < 'A' || (str[i] > 'Z' && str[i] < 'a') || str[i] > 'z') + { + return (0); + } + i++; + } + return (1); +} diff --git a/ended/C02/ex03/ft_str_is_numeric.c b/ended/C02/ex03/ft_str_is_numeric.c new file mode 100644 index 0000000..733076f --- /dev/null +++ b/ended/C02/ex03/ft_str_is_numeric.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_numeric.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 16:54:22 by ajoly #+# #+# */ +/* Updated: 2022/07/19 16:54:30 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_numeric(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0' ) + { + if (str[i] < '0' || str[i] > '9') + { + return (0); + } + i++; + } + return (1); +} diff --git a/ended/C02/ex04/ft_str_is_lowercase.c b/ended/C02/ex04/ft_str_is_lowercase.c new file mode 100644 index 0000000..21f156d --- /dev/null +++ b/ended/C02/ex04/ft_str_is_lowercase.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_lowercase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 15:48:34 by ajoly #+# #+# */ +/* Updated: 2022/07/19 15:48:39 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_lowercase(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0' ) + { + if (str[i] < 'a' || str[i] > 'z') + { + return (0); + } + i++; + } + return (1); +} diff --git a/ended/C02/ex05/ft_str_is_uppercase.c b/ended/C02/ex05/ft_str_is_uppercase.c new file mode 100644 index 0000000..b82007f --- /dev/null +++ b/ended/C02/ex05/ft_str_is_uppercase.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_uppercase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 16:02:59 by ajoly #+# #+# */ +/* Updated: 2022/07/19 16:03:03 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_uppercase(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0' ) + { + if (str[i] < 'A' || str[i] > 'Z') + { + return (0); + } + i++; + } + return (1); +} diff --git a/ended/C02/ex06/ft_str_is_printable.c b/ended/C02/ex06/ft_str_is_printable.c new file mode 100644 index 0000000..3afd549 --- /dev/null +++ b/ended/C02/ex06/ft_str_is_printable.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_printable.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 16:12:36 by ajoly #+# #+# */ +/* Updated: 2022/07/19 16:12:40 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_printable(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0' ) + { + if (str[i] < 32 || str[i] > 126) + { + return (0); + } + i++; + } + return (1); +} diff --git a/ended/C02/ex07/ft_strupcase.c b/ended/C02/ex07/ft_strupcase.c new file mode 100644 index 0000000..2a2779b --- /dev/null +++ b/ended/C02/ex07/ft_strupcase.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strupcase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 16:42:15 by ajoly #+# #+# */ +/* Updated: 2022/07/19 16:42:19 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strupcase(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + if (str[i] >= 'a' && str[i] <= 'z') + { + str[i] -= 32; + } + i++; + } + return (str); +} diff --git a/ended/C02/ex08/ft_strlowcase.c b/ended/C02/ex08/ft_strlowcase.c new file mode 100644 index 0000000..c202aac --- /dev/null +++ b/ended/C02/ex08/ft_strlowcase.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strupcase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 16:42:15 by ajoly #+# #+# */ +/* Updated: 2022/07/19 16:42:19 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strlowcase(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + if (str[i] >= 'A' && str[i] <= 'Z') + { + str[i] += 32; + } + i++; + } + return (str); +} diff --git a/ended/C02/ex09/ft_strcapitalize.c b/ended/C02/ex09/ft_strcapitalize.c new file mode 100644 index 0000000..86317d2 --- /dev/null +++ b/ended/C02/ex09/ft_strcapitalize.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcapitalize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/19 19:09:13 by ajoly #+# #+# */ +/* Updated: 2022/07/19 19:09:17 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcapitalize(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + if (str[i] >= 'a' && str[i] <= 'z') + { + if (str[i - 1] <= 47 || str[i - 1] == 0 + || (str[i - 1] >= 58 && str[i - 1] <= 64) + || (str[i - 1] >= 91 && str[i - 1] <= 96) + || (str[i - 1] >= 123 && str[i - 1] <= 126)) + { + str[i] -= 32; + } + } + if (str[i] >= 'A' && str[i] <= 'Z') + { + if (str[i - 1] > 47) + { + str[i] += 32; + } + } + i++; + } + return (str); +} diff --git a/ended/C02/ex10/ft_strlcpy.c b/ended/C02/ex10/ft_strlcpy.c new file mode 100644 index 0000000..27353dd --- /dev/null +++ b/ended/C02/ex10/ft_strlcpy.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/20 08:23:38 by ajoly #+# #+# */ +/* Updated: 2022/07/20 08:23:41 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +unsigned int ft_strlcpy(char *dest, char *src, unsigned int size) +{ + unsigned int i; + + i = 0; + if (size > 0) + { + while (--size && src[i]) + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + } + while (src[i]) + i++; + return (i); +} diff --git a/ended/C03-corr/ex00/ft_strcmp.c b/ended/C03-corr/ex00/ft_strcmp.c new file mode 100644 index 0000000..f9af39c --- /dev/null +++ b/ended/C03-corr/ex00/ft_strcmp.c @@ -0,0 +1,5 @@ +#include +int main() +{ + printf("%d", ft_strcmp("zfz", "gfg")); +} \ No newline at end of file diff --git a/ended/C03-corr/ex01/ft_strncmp.h b/ended/C03-corr/ex01/ft_strncmp.h new file mode 100644 index 0000000..f92226f --- /dev/null +++ b/ended/C03-corr/ex01/ft_strncmp.h @@ -0,0 +1,5 @@ +#include +int main() +{ + printf("%d", ft_strncmp("abcde", "abcda", 5)); +} \ No newline at end of file diff --git a/ended/C03-corr/ex02/strcat.c b/ended/C03-corr/ex02/strcat.c new file mode 100644 index 0000000..85d4a1f --- /dev/null +++ b/ended/C03-corr/ex02/strcat.c @@ -0,0 +1,10 @@ + +#include +int main(void) +{ + char ff[20] = "addfs f"; + char fl[20] = "adfda"; + + ft_strcat(ff, fl); + printf("%s", ff); +} \ No newline at end of file diff --git a/ended/C03-corr/ex03/strncat.c b/ended/C03-corr/ex03/strncat.c new file mode 100644 index 0000000..030eae9 --- /dev/null +++ b/ended/C03-corr/ex03/strncat.c @@ -0,0 +1,9 @@ +#include +int main(void) +{ + char ff[20] = "addfs "; + char fl[20] = "adfda"; + + ft_strncat(ff, fl, 9); + printf("%s", ff); +} diff --git a/ended/C03-corr/ex04/ft_strstr.c b/ended/C03-corr/ex04/ft_strstr.c new file mode 100644 index 0000000..7a53405 --- /dev/null +++ b/ended/C03-corr/ex04/ft_strstr.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%s", ft_strstr("fffff lll", "ll")); +} diff --git a/ended/C03/ex00/ft_strcmp.c b/ended/C03/ex00/ft_strcmp.c new file mode 100644 index 0000000..29baf08 --- /dev/null +++ b/ended/C03/ex00/ft_strcmp.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/20 16:55:23 by ajoly #+# #+# */ +/* Updated: 2022/07/20 16:55:30 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0') + { + i++; + } + return (s1[i] - s2[i]); +} diff --git a/ended/C03/ex01/ft_strncmp.c b/ended/C03/ex01/ft_strncmp.c new file mode 100644 index 0000000..1415342 --- /dev/null +++ b/ended/C03/ex01/ft_strncmp.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/21 10:14:08 by ajoly #+# #+# */ +/* Updated: 2022/07/21 10:14:11 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strncmp(char *s1, char *s2, unsigned int n) +{ + unsigned int i; + + i = 0; + if (n == 0) + { + return (0); + } + while (s1[i] == s2[i] && i + 1 < n && s1[i] != '\0' && s2[i] != '\0') + { + i++; + } + return (s1[i] - s2[i]); +} diff --git a/ended/C03/ex02/ft_strcat.c b/ended/C03/ex02/ft_strcat.c new file mode 100644 index 0000000..fc1fb20 --- /dev/null +++ b/ended/C03/ex02/ft_strcat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/21 15:08:59 by ajoly #+# #+# */ +/* Updated: 2022/07/21 15:11:10 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcat(char *dest, char *src) +{ + int i; + int l; + + i = 0; + l = 0; + while (dest[i] != '\0') + { + i++; + } + while (src[l] != '\0') + { + dest[i] = src[l]; + i++; + l++; + } + dest[i] = '\0'; + return (dest); +} diff --git a/ended/C03/ex03/ft_strncat.c b/ended/C03/ex03/ft_strncat.c new file mode 100644 index 0000000..9671681 --- /dev/null +++ b/ended/C03/ex03/ft_strncat.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/22 09:49:37 by ajoly #+# #+# */ +/* Updated: 2022/07/22 09:49:45 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strncat(char *dest, char *src, unsigned int nb) +{ + unsigned int i; + unsigned int l; + + i = 0; + l = 0; + while (dest[i] != '\0') + { + i++; + } + while (src[l] != '\0' && l < nb) + { + dest[i + l] = src[l]; + l++; + } + dest[i + l] = '\0'; + return (dest); +} diff --git a/ended/C03/ex04/ft_strstr.c b/ended/C03/ex04/ft_strstr.c new file mode 100644 index 0000000..764632b --- /dev/null +++ b/ended/C03/ex04/ft_strstr.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 10:18:22 by ajoly #+# #+# */ +/* Updated: 2022/07/25 10:18:26 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include + +char *ft_strstr(char *str, char *to_find) +{ + int i; + int j; + char *l[255]; + + i = 0; + j = 0; + if (str == 0) + { + return (NULL); + } + while (str[i] != '\0') + { + if (str[i] == to_find[j]) + { + str[j] = to_find[j]; + j++; + } + i++; + } + l[i] = '\0'; + return (*str); +} diff --git a/ended/C04-corr/ex00/ft_strlen.c b/ended/C04-corr/ex00/ft_strlen.c new file mode 100644 index 0000000..06336e5 --- /dev/null +++ b/ended/C04-corr/ex00/ft_strlen.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%d", ft_strlen("ffff")); +} diff --git a/ended/C04-corr/ex01/ft_putstr.c b/ended/C04-corr/ex01/ft_putstr.c new file mode 100644 index 0000000..0ed0cc7 --- /dev/null +++ b/ended/C04-corr/ex01/ft_putstr.c @@ -0,0 +1,4 @@ +int main(void) +{ + ft_putstr("fff"); +} diff --git a/ended/C04-corr/ex02/ft_putnbr.c b/ended/C04-corr/ex02/ft_putnbr.c new file mode 100644 index 0000000..450bf8a --- /dev/null +++ b/ended/C04-corr/ex02/ft_putnbr.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 13:03:53 by ajoly #+# #+# */ +/* Updated: 2022/07/25 13:03:55 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include + +void ft_putnbr(int nb) +{ + long nb_long; + int nb_temp; + int div; + + nb_long = nb; + div = 1; + if(nb_long < 0) + { + write(1, "-", 1); + nb_long *= -1; + } + while (nb_long / 10 >= div) + div *= 10; + while (div >= 1) + { + nb_temp = (nb_long / div) + 48; + write(1, &nb_temp, 1); + nb_long = nb_long % div; + div = div / 10; + } +} diff --git a/ended/C04-corr/ex03/ft_atoi.c b/ended/C04-corr/ex03/ft_atoi.c new file mode 100644 index 0000000..e79dad4 --- /dev/null +++ b/ended/C04-corr/ex03/ft_atoi.c @@ -0,0 +1,5 @@ +#include +int main() +{ + printf("%d\n", ft_atoi(" ---+-++123jkjh54984")); +} diff --git a/ended/C04-corr/ex04/ft_putnbr_base.c b/ended/C04-corr/ex04/ft_putnbr_base.c new file mode 100644 index 0000000..1a6ab40 --- /dev/null +++ b/ended/C04-corr/ex04/ft_putnbr_base.c @@ -0,0 +1,4 @@ +int main(void) +{ + ft_putnbr_base(126, "0123456789abcdef"); +} diff --git a/ended/C04/ex00/ft_strlen.c b/ended/C04/ex00/ft_strlen.c new file mode 100644 index 0000000..faa659f --- /dev/null +++ b/ended/C04/ex00/ft_strlen.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 10:23:43 by ajoly #+# #+# */ +/* Updated: 2022/07/25 10:23:45 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + i++; + return (i); +} diff --git a/ended/C04/ex01/ft_putstr.c b/ended/C04/ex01/ft_putstr.c new file mode 100644 index 0000000..9aa7fe1 --- /dev/null +++ b/ended/C04/ex01/ft_putstr.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 12:11:23 by ajoly #+# #+# */ +/* Updated: 2022/07/25 12:11:25 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include + +void ft_putstr(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + write(1, &str[i], 1); + i++; + } +} diff --git a/ended/C04/ex02/ft_putnbr.c b/ended/C04/ex02/ft_putnbr.c new file mode 100644 index 0000000..c425efc --- /dev/null +++ b/ended/C04/ex02/ft_putnbr.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 13:03:53 by ajoly #+# #+# */ +/* Updated: 2022/07/25 13:03:55 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include + +void ft_putnbr(int nb) +{ + long nb_long; + int nb_temp; + int div; + + nb_long = nb; + div = 1; + if (nb_long < 0) + { + write(1, "-", 1); + nb_long *= -1; + } + while (nb_long / 10 >= div) + div *= 10; + while (div >= 1) + { + nb_temp = (nb_long / div) + 48; + write(1, &nb_temp, 1); + nb_long = nb_long % div; + div = div / 10; + } +} diff --git a/ended/C04/ex03/ft_atoi.c b/ended/C04/ex03/ft_atoi.c new file mode 100644 index 0000000..d1a5017 --- /dev/null +++ b/ended/C04/ex03/ft_atoi.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/25 13:48:15 by ajoly #+# #+# */ +/* Updated: 2022/07/25 13:48:19 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_atoi(char *str) +{ + int i; + int result; + int neg; + + i = 0; + neg = 1; + result = 0; + while (str[i] == ' ' || str[i] == '\t' || str[i] == '\r' + || str[i] == '\n' || str[i] == '\v' || str[i] == '\f') + i++; + while (str[i] == '+' || str[i] == '-') + { + if (str[i] == '-') + neg *= -1; + i++; + } + while (str[i] >= '0' && str[i] <= '9') + { + result = result * 10 + (str[i] - 48); + i++; + } + return (result * neg); +} diff --git a/ended/C04/ex04/ft_putnbr_base.c b/ended/C04/ex04/ft_putnbr_base.c new file mode 100644 index 0000000..c12999e --- /dev/null +++ b/ended/C04/ex04/ft_putnbr_base.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/26 13:30:23 by ajoly #+# #+# */ +/* Updated: 2022/07/26 13:30:27 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include + +int check_base(char *base) +{ + int i; + + i = 0; + if (base[0] == '\0' && base[1] == '\0') + { + return (0); + } + while (base[i]) + { + if (base[i] < 26 || base[i] > 126) + return (0); + if (base[i] == '+' || base[i] == '-') + return (0); + if (base[i] == base[i + 1]) + return (0); + i++; + } + return (1); +} + +void ft_putnbr_base(int nbr, char *base) +{ + int base_count; + int i; + int final[255]; + + i = 0; + base_count = 0; + if (check_base(base)) + { + if (nbr < 0) + { + nbr = -nbr; + write(1, "-", 1); + } + while (base[base_count]) + base_count++; + while (nbr) + { + final[i] = nbr % base_count; + nbr = nbr / base_count; + i++; + } + while (--i >= 0) + write(1, &base[final[i]], 1); + } +} diff --git a/ended/C05-corr/ex00/ft_iterative_factorial.c b/ended/C05-corr/ex00/ft_iterative_factorial.c new file mode 100644 index 0000000..d4f51d4 --- /dev/null +++ b/ended/C05-corr/ex00/ft_iterative_factorial.c @@ -0,0 +1,4 @@ +int main(void) +{ + printf("%d", ft_iterative_factorial(126)); +} \ No newline at end of file diff --git a/ended/C05-corr/ex01/ft_recursive_factorial.c b/ended/C05-corr/ex01/ft_recursive_factorial.c new file mode 100644 index 0000000..19e226f --- /dev/null +++ b/ended/C05-corr/ex01/ft_recursive_factorial.c @@ -0,0 +1,4 @@ +int main(void) +{ + printf("%d", ft_recursive_factorial(126)); +} diff --git a/ended/C05-corr/ex02/ft_iterative_power.c b/ended/C05-corr/ex02/ft_iterative_power.c new file mode 100644 index 0000000..3155c7d --- /dev/null +++ b/ended/C05-corr/ex02/ft_iterative_power.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%d", ft_iterative_power(2, 2)); +} diff --git a/ended/C05-corr/ex03/ft_recursive_power.c b/ended/C05-corr/ex03/ft_recursive_power.c new file mode 100644 index 0000000..74a6cf0 --- /dev/null +++ b/ended/C05-corr/ex03/ft_recursive_power.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%d", ft_recursive_power(5, 2)); +} diff --git a/ended/C05-corr/ex04/ft_fibonacci.c b/ended/C05-corr/ex04/ft_fibonacci.c new file mode 100644 index 0000000..1beff00 --- /dev/null +++ b/ended/C05-corr/ex04/ft_fibonacci.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%d", ft_fibonacci(14)); +} diff --git a/ended/C05-corr/ex05/ft_sqrt.c b/ended/C05-corr/ex05/ft_sqrt.c new file mode 100644 index 0000000..b17bdf1 --- /dev/null +++ b/ended/C05-corr/ex05/ft_sqrt.c @@ -0,0 +1,5 @@ +#include +int main() +{ + printf("%d", ft_sqrt(8)); +} diff --git a/ended/C05-corr/ex06/ft_is_prime.c b/ended/C05-corr/ex06/ft_is_prime.c new file mode 100644 index 0000000..f1959de --- /dev/null +++ b/ended/C05-corr/ex06/ft_is_prime.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + printf("%d", ft_is_prime(12)); +} + diff --git a/ended/C05-corr/ex07/ft_find_next_prime.c b/ended/C05-corr/ex07/ft_find_next_prime.c new file mode 100644 index 0000000..7ae6900 --- /dev/null +++ b/ended/C05-corr/ex07/ft_find_next_prime.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + printf("%d", ft_find_next_prime(5)); +} diff --git a/ended/C05/ex00/ft_iterative_factorial.c b/ended/C05/ex00/ft_iterative_factorial.c new file mode 100644 index 0000000..e4cd60e --- /dev/null +++ b/ended/C05/ex00/ft_iterative_factorial.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 11:34:45 by ajoly #+# #+# */ +/* Updated: 2022/07/27 11:34:47 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_iterative_factorial(int nb) +{ + int i; + int result; + + i = 1; + result = 1; + if (nb < 0) + return (0); + if (nb == 0 || nb == 1) + return (1); + while (i <= nb) + { + result = i * result; + i++; + } + return (result); +} diff --git a/ended/C05/ex01/ft_recursive_factorial.c b/ended/C05/ex01/ft_recursive_factorial.c new file mode 100644 index 0000000..edc8798 --- /dev/null +++ b/ended/C05/ex01/ft_recursive_factorial.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 14:51:29 by ajoly #+# #+# */ +/* Updated: 2022/08/01 13:39:06 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_recursive_factorial(int nb) +{ + if (nb < 0) + return (0); + if (nb == 1 || nb == 0) + return (1); + return (nb * ft_recursive_factorial(nb - 1)); +} diff --git a/ended/C05/ex02/ft_iterative_power.c b/ended/C05/ex02/ft_iterative_power.c new file mode 100644 index 0000000..ca0db03 --- /dev/null +++ b/ended/C05/ex02/ft_iterative_power.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 16:42:03 by ajoly #+# #+# */ +/* Updated: 2022/07/27 16:42:04 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_iterative_power(int nb, int power) +{ + int i; + + i = 1; + if (power < 0) + return (0); + else if (power == 0) + return (1); + while (power > 0) + { + i = i * nb; + power--; + } + return (i); +} diff --git a/ended/C05/ex03/ft_recursive_power.c b/ended/C05/ex03/ft_recursive_power.c new file mode 100644 index 0000000..8509535 --- /dev/null +++ b/ended/C05/ex03/ft_recursive_power.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 18:32:22 by ajoly #+# #+# */ +/* Updated: 2022/07/27 18:51:35 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_recursive_power(int nb, int power) +{ + if (power < 0) + return (0); + else if (power == 0) + return (1); + return (nb * ft_recursive_power(nb, power - 1)); +} diff --git a/ended/C05/ex04/ft_fibonacci.c b/ended/C05/ex04/ft_fibonacci.c new file mode 100644 index 0000000..1f11bd6 --- /dev/null +++ b/ended/C05/ex04/ft_fibonacci.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_fibonacci.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 18:51:47 by ajoly #+# #+# */ +/* Updated: 2022/07/27 18:51:48 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_fibonacci(int index) +{ + if (index < 0) + return (-1); + if (index == 0) + return (0); + if (index == 1) + return (1); + return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2)); +} diff --git a/ended/C05/ex05/ft_sqrt.c b/ended/C05/ex05/ft_sqrt.c new file mode 100644 index 0000000..92904fe --- /dev/null +++ b/ended/C05/ex05/ft_sqrt.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sqrt.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/27 21:41:03 by ajoly #+# #+# */ +/* Updated: 2022/08/01 15:57:14 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_sqrt(int nb) +{ + int i; + + i = 1; + while (i * i < nb && i <= nb / 2) + i++; + if ((nb % i) == 0) + return (i); + return (0); +} + +#include +int main() +{ + printf("%d", ft_sqrt(__INT_MAX__)); +} \ No newline at end of file diff --git a/ended/C05/ex06/ft_is_prime.c b/ended/C05/ex06/ft_is_prime.c new file mode 100644 index 0000000..8572dec --- /dev/null +++ b/ended/C05/ex06/ft_is_prime.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_prime.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 10:27:29 by ajoly #+# #+# */ +/* Updated: 2022/08/01 15:58:00 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_is_prime(int nb) +{ + int i; + + i = 2; + if (nb <= 1) + return (0); + while (i <= nb / i) + { + if (nb % i == 0) + return (0); + i++; + } + return (1); +} diff --git a/ended/C05/ex07/ft_find_next_prime.c b/ended/C05/ex07/ft_find_next_prime.c new file mode 100644 index 0000000..5751600 --- /dev/null +++ b/ended/C05/ex07/ft_find_next_prime.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_find_next_prime.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/29 10:45:00 by ajoly #+# #+# */ +/* Updated: 2022/08/01 15:57:50 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_is_prime(int nb) +{ + int i; + + i = 2; + if (nb <= 1) + return (0); + while (i <= nb / i) + { + if (nb % i == 0) + return (0); + i++; + } + return (1); +} + +int ft_find_next_prime(int nb) +{ + int i; + + i = nb; + while (ft_is_prime(i) != 1) + { + i++; + } + return (i); +} diff --git a/ended/C06/ex00/ft_print_program_name.c b/ended/C06/ex00/ft_print_program_name.c new file mode 100644 index 0000000..18adcb5 --- /dev/null +++ b/ended/C06/ex00/ft_print_program_name.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_program_name.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 14:40:17 by ajoly #+# #+# */ +/* Updated: 2022/08/02 14:15:41 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + + i = 0; + if (argc >= 1) + { + while (argv[0][i]) + { + write(1, &argv[0][i], 1); + i++; + } + write(1, "\n", 1); + } +} diff --git a/ended/C06/ex01/ft_print_params.c b/ended/C06/ex01/ft_print_params.c new file mode 100644 index 0000000..2266813 --- /dev/null +++ b/ended/C06/ex01/ft_print_params.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 16:07:09 by ajoly #+# #+# */ +/* Updated: 2022/08/02 14:12:31 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + int j; + + i = 1; + if (argc >= 1) + { + while (argv[i]) + { + j = 0; + while (argv[i][j]) + { + write(1, &argv[i][j], 1); + j++; + } + write(1, "\n", 1); + i++; + } + } +} diff --git a/ended/C06/ex02/ft_rev_params.c b/ended/C06/ex02/ft_rev_params.c new file mode 100644 index 0000000..0b77291 --- /dev/null +++ b/ended/C06/ex02/ft_rev_params.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_rev_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 16:30:21 by ajoly #+# #+# */ +/* Updated: 2022/08/01 10:43:28 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + int j; + + i = argc; + while (i > 1) + { + i--; + j = 0; + while (argv[i][j]) + { + write(1, &argv[i][j], 1); + j++; + } + write(1, "\n", 1); + } +} diff --git a/ended/C06/ex03/ft_sort_params.c b/ended/C06/ex03/ft_sort_params.c new file mode 100644 index 0000000..7cb6d24 --- /dev/null +++ b/ended/C06/ex03/ft_sort_params.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 16:57:15 by ajoly #+# #+# */ +/* Updated: 2022/08/02 10:29:03 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0') + { + i++; + } + return (s1[i] - s2[i]); +} + +void ft_print_argv(char **argv) +{ + int i; + int j; + + i = 1; + while (argv[i]) + { + j = 0; + while (argv[i][j]) + { + write(1, &argv[i][j], 1); + j++; + } + write(1, "\n", 1); + i++; + } +} + +int main(int argc, char **argv) +{ + int i; + int j; + char *temp; + + i = 1; + while (i < argc) + { + j = 1; + while (j < argc - i) + { + if (ft_strcmp(argv[j], argv[j + 1]) > 0) + { + temp = argv[j]; + argv[j] = argv[j + 1]; + argv[j + 1] = temp; + } + j++; + } + i++; + } + ft_print_argv(argv); +} diff --git a/ended/C07-corr/ex00/ft_strdup.c b/ended/C07-corr/ex00/ft_strdup.c new file mode 100644 index 0000000..bea952c --- /dev/null +++ b/ended/C07-corr/ex00/ft_strdup.c @@ -0,0 +1,9 @@ +#include +int main(void) +{ + char *cpy = ft_strdup("lll lll fff"); + + printf("%s", cpy); + free(cpy); + return (0); +} diff --git a/ended/C07-corr/ex01/ft_range.c b/ended/C07-corr/ex01/ft_range.c new file mode 100644 index 0000000..8724b63 --- /dev/null +++ b/ended/C07-corr/ex01/ft_range.c @@ -0,0 +1,15 @@ +#include +int main(void) +{ + int *l = ft_range(5, 10); + int i = 0; + + while(l[i]) + { + printf("%d", l[i]); + i++; + } + + free(l); + return (0); +} \ No newline at end of file diff --git a/ended/C07-corr/ex02/ft_ultimate_range.c b/ended/C07-corr/ex02/ft_ultimate_range.c new file mode 100644 index 0000000..3e377f3 --- /dev/null +++ b/ended/C07-corr/ex02/ft_ultimate_range.c @@ -0,0 +1,21 @@ +#include +int main () +{ + int max; + int min; + int *tab; + int size; + int j; + + min = 12; + max = 15; + size = max-min; + j = ft_ultimate_range(&tab, min, max); + int i = 0; + while (i < size) + { + printf("%d\n", tab[i]); + printf("%d", j); + i++; + } +} \ No newline at end of file diff --git a/ended/C07-corr/ex03/ft_strjoin.c b/ended/C07-corr/ex03/ft_strjoin.c new file mode 100644 index 0000000..f2c5499 --- /dev/null +++ b/ended/C07-corr/ex03/ft_strjoin.c @@ -0,0 +1,16 @@ +#include +int main (void) +{ + char *sep; + char *tab[50]; + char *j; + + tab[0] = "Hello"; + tab[1] = "World"; + tab[2] = "ffdsfadf"; + sep = ";"; + j = ft_strjoin(3, tab, sep); + printf("%s", j); + free(j); + return (0); +} \ No newline at end of file diff --git a/ended/C07/ex00/ft_strdup.c b/ended/C07/ex00/ft_strdup.c new file mode 100644 index 0000000..343503f --- /dev/null +++ b/ended/C07/ex00/ft_strdup.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/28 18:42:08 by ajoly #+# #+# */ +/* Updated: 2022/08/04 09:17:22 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +char *ft_strdup(char *src) +{ + int i; + char *dest; + + i = 0; + while (src[i]) + i++; + dest = malloc(i); + i = 0; + while (src[i]) + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +} diff --git a/ended/C07/ex01/ft_range.c b/ended/C07/ex01/ft_range.c new file mode 100644 index 0000000..a456866 --- /dev/null +++ b/ended/C07/ex01/ft_range.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/01 15:14:57 by ajoly #+# #+# */ +/* Updated: 2022/08/04 12:52:11 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int *ft_range(int min, int max) +{ + int i; + int *result; + int diff; + + diff = max - min; + result = malloc((diff + 1) * sizeof(int)); + i = 0; + if (min >= max) + { + result = NULL; + return (result); + } + while (min < max) + { + result[i] = min; + i++; + min++; + } + return (result); +} diff --git a/ended/C07/ex02/ft_ultimate_range.c b/ended/C07/ex02/ft_ultimate_range.c new file mode 100644 index 0000000..0be7a4d --- /dev/null +++ b/ended/C07/ex02/ft_ultimate_range.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultimate_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/02 21:00:29 by ajoly #+# #+# */ +/* Updated: 2022/08/03 14:55:34 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_ultimate_range(int **range, int min, int max) +{ + int i; + int *result; + int diff; + + diff = max - min; + result = malloc((diff + 1) * sizeof(int)); + i = 0; + if (min >= max) + { + *range = NULL; + return (0); + } + while (min < max) + { + result[i] = min; + i++; + min++; + } + *range = result; + return (i); +} diff --git a/ended/C07/ex03/ft_strjoin.c b/ended/C07/ex03/ft_strjoin.c new file mode 100644 index 0000000..e6d48d4 --- /dev/null +++ b/ended/C07/ex03/ft_strjoin.c @@ -0,0 +1,73 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/03 09:24:30 by ajoly #+# #+# */ +/* Updated: 2022/08/04 11:16:46 by ajoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +char *ft_strcat(char *dest, char *src) +{ + int i; + int l; + + i = 0; + l = 0; + while (dest[i] != '\0') + i++; + while (src[l] != '\0') + { + dest[i] = src[l]; + i++; + l++; + } + dest[i] = '\0'; + return (dest); +} + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} + +char *ft_strjoin(int size, char **strs, char *sep) +{ + int i; + char *result; + int len; + + i = -1; + len = ft_strlen(sep) * (size - 1); + while (++i < size) + len = len + ft_strlen(strs[i]); + if (size == 0) + { + result = malloc(sizeof(char)); + *result = 0; + return (result); + } + i = 0; + result = malloc(len); + while (i < size) + { + ft_strcat(result, strs[i]); + if (i < size - 1) + ft_strcat(result, sep); + i++; + } + result[len] = '\0'; + return (result); +} diff --git a/ended/rush01/ex00/checks.c b/ended/rush01/ex00/checks.c new file mode 100644 index 0000000..0135413 --- /dev/null +++ b/ended/rush01/ex00/checks.c @@ -0,0 +1,138 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* checks.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:33:44 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 15:14:35 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int left_to_right(int **arr_answer, int row, int expected) +{ + int i; + int j; + int count; + int if_increasing; + + i = 0; + count = 1; + while (arr_answer[row][i] <= 3) + { + j = i; + if_increasing = i; + while (j > 0) + { + if (arr_answer[row][i] > arr_answer[row][j - 1]) + if_increasing--; + j--; + } + if (j == if_increasing) + count++; + i++; + } + return (count == expected); +} + +int up_to_down(int **arr_answer, int col, int expected) +{ + int i; + int j; + int count; + int if_increasing; + + i = 0; + count = 1; + while (i < 4 && arr_answer[i][col] <= 3) + { + j = i; + if_increasing = i; + while (j > 0) + { + if (arr_answer[i][col] > arr_answer[j - 1][col]) + if_increasing--; + j--; + } + if (j == if_increasing) + count++; + i++; + } + return (count == expected); +} + +int right_to_left(int **arr_answer, int row, int expected) +{ + int i; + int j; + int count; + int if_increasing; + + i = 3; + count = 1; + while (arr_answer[row][i] <= 3) + { + j = i; + if_increasing = i; + while (j < 3) + { + if (arr_answer[row][i] > arr_answer[row][j + 1]) + if_increasing++; + j++; + } + if (j == if_increasing) + count++; + i--; + } + return (count == expected); +} + +int down_to_up(int **arr_answer, int col, int expected) +{ + int i; + int j; + int count; + int if_increasing; + + i = 3; + count = 1; + while (i > 0 && arr_answer[i][col] <= 3) + { + j = i; + if_increasing = i; + while (j < 3) + { + if (arr_answer[i][col] > arr_answer[j + 1][col]) + if_increasing++; + j++; + } + if (j == if_increasing) + count++; + i--; + } + return (count == expected); +} + +int check_duplicates(int **board) +{ + int i; + int j; + int k; + + i = -1; + while (++i < 4) + { + j = -1; + while (++j < 4) + { + k = j; + while (++k < 4) + { + if (board[j][i] == board[k][i]) + return (0); + } + } + } + return (1); +} diff --git a/ended/rush01/ex00/checks.h b/ended/rush01/ex00/checks.h new file mode 100644 index 0000000..2edbb7f --- /dev/null +++ b/ended/rush01/ex00/checks.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* checks.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:45:31 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 15:14:11 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef CHECKS_H +# define CHECKS_H + +int left_to_right(int **arr_answer, int row, int expected); +int up_to_down(int **arr_answer, int col, int expected); +int right_to_left(int **arr_answer, int row, int expected); +int down_to_up(int **arr_answer, int col, int expected); +int check_duplicates(int **board); + +#endif diff --git a/ended/rush01/ex00/lib.c b/ended/rush01/ex00/lib.c new file mode 100644 index 0000000..181eac7 --- /dev/null +++ b/ended/rush01/ex00/lib.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:26:42 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 16:16:26 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_putstr(char *str) +{ + int i; + + i = -1; + while (str[++i]) + write(1, &str[i], 1); +} + +void ft_swap(int *i, int *j) +{ + int temp; + + temp = *i; + *i = *j; + *j = temp; +} diff --git a/ended/rush01/ex00/lib.h b/ended/rush01/ex00/lib.h new file mode 100644 index 0000000..d31e38d --- /dev/null +++ b/ended/rush01/ex00/lib.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:44:57 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 14:44:59 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIB_H +# define LIB_H + +void ft_putchar(char c); +void ft_putstr(char *str); +void ft_swap(int *i, int *j); + +#endif diff --git a/ended/rush01/ex00/main.c b/ended/rush01/ex00/main.c new file mode 100644 index 0000000..2aca702 --- /dev/null +++ b/ended/rush01/ex00/main.c @@ -0,0 +1,137 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/23 18:04:54 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 13:58:55 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "checks.h" +#include "parser.h" +#include "permutations.h" +#include "lib.h" + +void print_board(int **board, int count) +{ + int i; + int j; + + if (count == 4) + { + i = -1; + while (++i < 4) + { + j = -1; + while (++j < 4) + { + ft_putchar(board[i][j] + '0'); + if (j < 3) + ft_putchar(' '); + } + ft_putchar('\n'); + } + exit(0); + } + free(board); +} + +int **create_board(int *permut_1, int *permut_2, int *permut_3, int *permut_4) +{ + int **board; + int i; + + board = (int **) malloc(4 * sizeof(int *)); + i = -1; + while (++i < 4) + board[i] = (int *) malloc(4 * sizeof(int)); + i = -1; + while (++i < 4) + board[0][i] = permut_1[i]; + i = -1; + while (++i < 4) + board[1][i] = permut_2[i]; + i = -1; + while (++i < 4) + board[2][i] = permut_3[i]; + i = -1; + while (++i < 4) + board[3][i] = permut_4[i]; + return (board); +} + +void solve_board(int **board, int **arr_expected) +{ + int i; + int count; + + i = 0; + count = 0; + if (check_duplicates(board)) + { + while (i < 4) + { + if (up_to_down(board, i, arr_expected[0][i]) + && down_to_up(board, i, arr_expected[1][i]) + && left_to_right(board, i, arr_expected[2][i]) + && right_to_left(board, i, arr_expected[3][i])) + count++; + i++; + } + } + print_board(board, count); +} + +void solve_all_boards(int **permutations, int **arr_expected) +{ + int line_1; + int line_2; + int line_3; + int line_4; + + line_1 = -1; + while (++line_1 < 24) + { + line_2 = -1; + while (++line_2 < 24) + { + line_3 = -1; + while (++line_3 < 24) + { + line_4 = -1; + while (++line_4 < 24) + { + solve_board(create_board(permutations[line_1], + permutations[line_2], permutations[line_3], + permutations[line_4]), arr_expected); + } + } + } + } + ft_putstr("Error\n"); +} + +int main(int argc, char **argv) +{ + int **permutations; + int **check; + + if (argc == 2) + { + if (check_input(argv[1])) + { + check = str_to_tab(argv[1]); + permutations = generate_permutations(); + solve_all_boards(permutations, check); + free(permutations); + free(check); + return (0); + } + } + ft_putstr("Error\n"); + return (0); +} diff --git a/ended/rush01/ex00/parser.c b/ended/rush01/ex00/parser.c new file mode 100644 index 0000000..5a84b74 --- /dev/null +++ b/ended/rush01/ex00/parser.c @@ -0,0 +1,61 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parser.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:28:23 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 14:28:26 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int check_input(char *str) +{ + int i; + + i = -1; + while (str[++i]) + { + if (i % 2 == 1) + { + if (str[i] != ' ') + return (0); + } + else if (i % 2 == 0) + { + if (str[i] < '1' || str[i] > '4') + return (0); + } + } + if (i != 31) + return (0); + return (1); +} + +int **str_to_tab(char *str) +{ + int i; + int j; + int k; + int **check; + + i = -1; + check = (int **) malloc(4 * sizeof(int *)); + while (++i < 4) + check[i] = (int *) malloc(4 * sizeof(int)); + i = -1; + k = 0; + while (++i < 4) + { + j = -1; + while (++j < 4) + { + check[i][j] = str[k] - '0'; + k += 2; + } + } + return (check); +} diff --git a/ended/rush01/ex00/parser.h b/ended/rush01/ex00/parser.h new file mode 100644 index 0000000..4e3e83f --- /dev/null +++ b/ended/rush01/ex00/parser.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parser.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:45:05 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 14:45:08 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef PARSER_H +# define PARSER_H + +int check_input(char *str); +int **str_to_tab(char *str); + +#endif diff --git a/ended/rush01/ex00/permutations.c b/ended/rush01/ex00/permutations.c new file mode 100644 index 0000000..cbb570b --- /dev/null +++ b/ended/rush01/ex00/permutations.c @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* permutations.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:35:22 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 14:35:25 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "lib.h" + +int perm_next(int n[]) +{ + int tail; + int i; + int j; + + i = 3; + while (i > 0 && n[i - 1] >= n[i]) + i--; + tail = i; + if (tail > 0) + { + j = 3; + while (j > tail && n[j] <= n[tail - 1]) + j--; + ft_swap(&n[tail - 1], &n[j]); + } + i = tail; + j = 3; + while (i < j) + { + ft_swap(&n[i], &n[j]); + i++; + j--; + } + return (tail != 0); +} + +int **generate_permutations(void) +{ + int **permut; + int perm[4]; + int i; + int j; + + permut = (int **) malloc(24 * sizeof(int *)); + j = 0; + i = 0; + while (++i <= 4) + perm[i - 1] = i; + while (1) + { + permut[j] = (int *) malloc(4 * sizeof(int)); + i = -1; + while (++i < 4) + permut[j][i] = perm[i]; + j++; + if (!perm_next(perm)) + break ; + } + return (permut); +} diff --git a/ended/rush01/ex00/permutations.h b/ended/rush01/ex00/permutations.h new file mode 100644 index 0000000..6058df6 --- /dev/null +++ b/ended/rush01/ex00/permutations.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* permutations.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kjimenez +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/24 14:45:13 by kjimenez #+# #+# */ +/* Updated: 2022/07/24 15:50:47 by kjimenez ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef PERMUTATIONS_H +# define PERMUTATIONS_H + +int **generate_permutations(void); +int perm_next(int n[], int count); + +#endif diff --git a/ended/rush02/ex00/Makefile b/ended/rush02/ex00/Makefile new file mode 100644 index 0000000..655997f --- /dev/null +++ b/ended/rush02/ex00/Makefile @@ -0,0 +1,30 @@ + +SRCS = ft_main.c ft_errors.c ft_parse_dict.c ft_parse_line.c ft_parser.c ft_utils1.c ft_cut_nbr.c rush02.h + +OBJS = ${SRCS:.c=.o} + +NAME = rush-02 + +CC = gcc + +CFLAGS = -Wall -Werror -Wextra + +RM = rm -f + +.c.o: + ${CC} ${CFLAGS} -c $< -o ${<:.c=.o} + +${NAME}: ${OBJS} + ${CC} -o ${NAME} ${OBJS} + +all: ${NAME} + +clean: + ${RM} ${OBJS} + +fclean: clean + ${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re diff --git a/ended/rush02/ex00/ft_cut_nbr.c b/ended/rush02/ex00/ft_cut_nbr.c new file mode 100644 index 0000000..0be4682 --- /dev/null +++ b/ended/rush02/ex00/ft_cut_nbr.c @@ -0,0 +1,109 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_cut_nbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lvincent +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/31 19:07:48 by julemart #+# #+# */ +/* Updated: 2022/07/31 23:35:38 by lvincent ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +char **i_is_1(char **tab, char *nbr) +{ + char *temp; + + temp = malloc(2); + if (nbr[1] == '1') + { + temp[0] = nbr[1]; + temp[1] = nbr[2]; + tab = add_tab_str(tab, temp); + } + else if (nbr[1] != '0') + { + temp[0] = nbr[1]; + temp[1] = '0'; + tab = add_tab_str(tab, temp); + } + return (tab); +} + +char **ft_number(char **tab, char *nbr) +{ + int i; + char *temp; + + i = 0; + temp = malloc(2); + temp[1] = '\0'; + while (nbr[i]) + { + if (i == 0 && nbr[i] != '0') + { + temp[0] = nbr[i]; + tab = add_tab_str(tab, temp); + tab = add_tab_str(tab, "100"); + } + else if (i == 1) + { + if (nbr[i] == '1') + i++; + tab = i_is_1(tab, nbr); + } + if (i == 2 && nbr[i] != '0') + { + temp[0] = nbr[i]; + tab = add_tab_str(tab, temp); + } + i++; + } + return (tab); +} + +char *set_zeros(char *str) +{ + int i; + char *test; + + i = ft_strlen(str); + if (i % 3 == 1) + { + str = ft_addchar(str, '0'); + str = ft_addchar(str, '0'); + } + if (i % 3 == 2) + { + str = ft_addchar(str, '0'); + } + return (str); +} + +char **ft_comp(char *str) +{ + int i; + int j; + char *c; + char **tab; + + tab = malloc(sizeof(char *)); + c = malloc(4); + c[3] = '\0'; + j = 0; + i = 0; + while (str[i] != '\0') + { + j = 0; + while (j < 3) + { + c[j] = str[i + j]; + j++; + } + tab = ft_number(tab, c); + i += 3; + } + return (tab); +} diff --git a/ended/rush02/ex00/ft_errors.c b/ended/rush02/ex00/ft_errors.c new file mode 100644 index 0000000..b8440d2 --- /dev/null +++ b/ended/rush02/ex00/ft_errors.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_errors.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ajoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/30 17:50:28 by lvincent #+# #+# */ +/* Updated: 2022/07/31 15:09:03 by julemart ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +void ft_error(void) +{ + write(1, "Error\n", 6); +} + +void ft_dict_error(void) +{ + write(1, "Dict Error\n", 11); +} diff --git a/ended/rush02/ex00/ft_main.c b/ended/rush02/ex00/ft_main.c new file mode 100644 index 0000000..5347ef3 --- /dev/null +++ b/ended/rush02/ex00/ft_main.c @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lvincent +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/31 15:11:39 by julemart #+# #+# */ +/* Updated: 2022/07/31 23:24:25 by lvincent ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +int main(int argc, char **argv) +{ + char **tab_line; + int i; + char *nbr; + struct s_nb *line; + + if (argc == 3) + { + tab_line = ft_dict_to_line(argv[1]); + nbr = argv[2]; + } + if (argc == 2) + { + tab_line = ft_dict_to_line("numbers.dict.txt"); + nbr = argv[1]; + } + if (argc <= 3 && argc > 1) + { + if (!ft_parse(nbr)) + { + ft_error(); + return (0); + } + ft_trim(nbr); + while (tab_line[i]) + { + i++; + } + line = malloc(sizeof(struct s_nb) * i); + i = 0; + while (tab_line[i]) + { + line[i] = ft_parse_line(tab_line[i]); + i++; + } + while (tab_line[i]) + { + free(tab_line[i]); + i++; + } + free(line); + free(tab_line); + } + return (0); +} diff --git a/ended/rush02/ex00/ft_parse_dict.c b/ended/rush02/ex00/ft_parse_dict.c new file mode 100644 index 0000000..76a8e60 --- /dev/null +++ b/ended/rush02/ex00/ft_parse_dict.c @@ -0,0 +1,113 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parse_dict.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: julemart +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/30 18:30:17 by julemart #+# #+# */ +/* Updated: 2022/07/31 15:20:02 by julemart ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +char **ft_cut_line2(char *str, char **tab, int count_line, int i) +{ + int j; + int k; + + while (str[i]) + { + j = i; + while (str[i] != '\n' && str[i]) + i++; + tab[count_line] = malloc(sizeof(char) * (i - j + 1)); + k = 0; + while (str[j] != '\n' && str[j]) + { + tab[count_line][k] = str[j]; + j++; + k++; + } + if (k > 0) + tab[count_line][k] = '\0'; + if (k > 0) + count_line++; + else + free(tab[count_line]); + i++; + } + return (tab); +} + +char **ft_cut_line(char *str) +{ + int i; + int count_line; + char **tab; + + i = 0; + count_line = 1; + while (str[i]) + { + if (str[i] == '\n' && str[i - 1] != '\n') + count_line++; + i++; + } + tab = malloc(sizeof(char *) * (count_line)); + i = 0; + count_line = 0; + tab = ft_cut_line2(str, tab, count_line, i); + return (tab); +} + +char **ft_dict_to_line(char *path) +{ + int fd; + int size; + char tmp[1]; + char *str; + char **tab_line; + + size = 0; + fd = open(path, O_RDONLY); + if (fd == -1) + { + ft_dict_error(); + return (NULL); + } + while (read(fd, tmp, 1)) + size++; + close(fd); + str = malloc(sizeof(char) * (size + 1)); + fd = open(path, O_RDONLY); + read(fd, str, size); + close(fd); + str[size] = '\0'; + tab_line = ft_cut_line(str); + free(str); + return (tab_line); +} + +int main(void) +{ + char **tab_line; + int i; + + i = 0; + tab_line = ft_dict_to_line("numbers.dict.txt"); + while (tab_line[i]) + { + printf("%s\n", tab_line[i]); + i++; + } + i = 0; + while (tab_line[i]) + { + free(tab_line[i]); + i++; + } + free(tab_line); + return (0); +} diff --git a/ended/rush02/ex00/ft_parse_line.c b/ended/rush02/ex00/ft_parse_line.c new file mode 100644 index 0000000..326910a --- /dev/null +++ b/ended/rush02/ex00/ft_parse_line.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parse_line.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: julemart +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/31 15:38:42 by julemart #+# #+# */ +/* Updated: 2022/07/31 15:40:22 by julemart ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +char *ft_addchar(char *str, char c) +{ + char *return_val; + int i; + + i = 0; + while (str[i++]) + ; + return_val = malloc(i + 2); + i = 0; + while (str[i] != '\0') + { + return_val[i] = str[i]; + i++; + } + return_val[i++] = c; + return_val[i] = '\0'; + free(str); + return (return_val); +} + +struct s_nb ft_parse_line(char *line) +{ + struct s_nb result; + int i; + + result.nbr = malloc(1); + result.txt = malloc(1); + i = 0; + if (line[0] < '0' || line [0] > '9') + return (result); + while (line[i] >= '0' && line[i] <= '9') + { + result.nbr = ft_addchar(result.nbr, line[i]); + i++; + } + while (line[i] == ' ') + i++; + i++; + while (line[i] == ' ') + i++; + while (line[i] != '\n') + { + result.txt = ft_addchar(result.txt, line[i]); + i++; + } + return (result); +} diff --git a/ended/rush02/ex00/ft_parser.c b/ended/rush02/ex00/ft_parser.c new file mode 100644 index 0000000..be3190b --- /dev/null +++ b/ended/rush02/ex00/ft_parser.c @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parser.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lvincent +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/30 17:19:40 by lvincent #+# #+# */ +/* Updated: 2022/07/31 16:20:45 by lvincent ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +#define UI_MAX 4294967295 + +int ft_parse(char *str) +{ + int i; + int len; + + i = 0; + while (ft_is_whitespace(str[i]) && str[i]) + i++; + if (i >= ft_strlen(str)) + return (0); + while (str[i]) + { + if (ft_is_whitespace(str[i])) + break ; + else if ((str[i] < '0' || str[i] > '9') && !ft_is_whitespace(str[i])) + return (0); + i++; + } + while (str[i]) + { + if (!ft_is_whitespace(str[i])) + return (0); + i++; + } + return (1); +} + +char *ft_trim(char *str) +{ + int i; + int j; + + i = 0; + while (str[i] && ft_is_whitespace(str[i])) + i++; + j = i; + while (str[i] && !ft_is_whitespace(str[i])) + i++; + if (i < ft_strlen(str)) + str[i] = '\0'; + return (str + j); +} diff --git a/ended/rush02/ex00/ft_utils1.c b/ended/rush02/ex00/ft_utils1.c new file mode 100644 index 0000000..5422be2 --- /dev/null +++ b/ended/rush02/ex00/ft_utils1.c @@ -0,0 +1,96 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_utils1.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lvincent +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/30 17:50:34 by lvincent #+# #+# */ +/* Updated: 2022/07/31 23:32:52 by lvincent ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "rush02.h" + +int ft_is_whitespace(char c) +{ + if ((c >= 9 && c <= 13) || c == ' ') + return (1); + else + return (0); +} + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + i++; + return (i); +} + +char *ft_addchar(char *str, char c) +{ + char *return_val; + int i; + + i = 0; + while (str[i++]) + ; + return_val = malloc(i + 1); + i = 0; + return_val[0] = c; + while (str[i] != '\0') + { + return_val[i + 1] = str[i]; + i++; + } + return_val[i + 1] = '\0'; + free(str); + return (return_val); +} + +char *ft_set_string_malloc(char *str) +{ + char *r_value; + int i; + + r_value = malloc(ft_strlen(str)); + i = 0; + while (str[i]) + { + r_value[i] = str[i]; + i++; + } + r_value[i] = '\0'; + return (r_value); +} + +char **add_tab_str(char **tab, char *str) +{ + char **tmp; + int i; + int size; + + i = 0; + size = 0; + while (tab[i]) + { + size += ft_strlen(tab[i]); + i++; + } + i = 0; + tmp = malloc(size); + while (tab[i]) + { + tmp[i] = malloc(ft_strlen(tab[i])); + tmp[i] = tab[i]; + i++; + } + tmp[i] = malloc(ft_strlen(tab[i])); + tmp[i] = str; + puts("yes"); + free(tab); + return (tmp); +} diff --git a/ended/rush02/ex00/rush02.h b/ended/rush02/ex00/rush02.h new file mode 100644 index 0000000..c7c3815 --- /dev/null +++ b/ended/rush02/ex00/rush02.h @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* rush02.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lvincent +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/07/31 23:23:19 by lvincent #+# #+# */ +/* Updated: 2022/07/31 23:30:37 by lvincent ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef RUSH02_H +# define RUSH02_H + +# include +# include +# include + +struct s_nb +{ + char *nbr; + char *txt; +}; + +char *ft_addchar(char *str, char c); +struct s_nb ft_parse_line(char *line); +void ft_error(void); +void ft_dict_error(void); +int ft_strlen(char *str); +int ft_is_whitespace(char c); +char **ft_cut_line2(char *str, char **tab, int count_line, int i); +char **ft_cut_line(char *str); +char **ft_dict_to_line(char *path); +int ft_parse(char *str); +char *ft_trim(char *str); +char *ft_set_string_malloc(char *str); +char **add_tab_char(char **tab, char c); +char **add_tab_str(char **tab, char *str); +char **i_is_1(char **tab, char *nbr); +char **ft_number(char **tab, char *nbr); +char *set_zeros(char *str); +char **ft_comp(char *str); + +#endif diff --git a/ended/shell00/.gitignore b/ended/shell00/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ended/shell00/ex00/z b/ended/shell00/ex00/z new file mode 100644 index 0000000..e900b1c --- /dev/null +++ b/ended/shell00/ex00/z @@ -0,0 +1 @@ +Z diff --git a/ended/shell00/ex01/testShell00 b/ended/shell00/ex01/testShell00 new file mode 100644 index 0000000..6f753eb --- /dev/null +++ b/ended/shell00/ex01/testShell00 @@ -0,0 +1 @@ +000000000000000000000000000000000000000 diff --git a/ended/shell00/ex01/testShell00.tar b/ended/shell00/ex01/testShell00.tar new file mode 100644 index 0000000..440cc3f Binary files /dev/null and b/ended/shell00/ex01/testShell00.tar differ diff --git a/ended/shell00/ex02/exo2.tar b/ended/shell00/ex02/exo2.tar new file mode 100755 index 0000000..476f28a Binary files /dev/null and b/ended/shell00/ex02/exo2.tar differ diff --git a/ended/shell00/ex03/id_rsa_pub b/ended/shell00/ex03/id_rsa_pub new file mode 100644 index 0000000..01236cb --- /dev/null +++ b/ended/shell00/ex03/id_rsa_pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCze8eoXR5W8hFm5Vfx7/Q98HDKWzCyRLN9C2HnafTS1EvvMfBNBTOetzVCSru6vaJdJS8z6/RTBtreW4zmhItug3buqGftddDFCgyX6qDTLjEGQLCJil8m2a9i28L5WTLItsbS2gWVSL8iWujqBMy32UQ72zyztvlrE9BHMzpX5yPAg398N0eYTqM2WdDn9Zefgv88jOmENEqA3Re14UaIoBkO6gL1KMQPFUxvqaZ1i351HP6e035UZN/Rle27R4nrzI/uzfmW0tUEMdzpnpc+SMg7V5US5n0L/0T3T0c3hXeJhey3IzoqYhGWhcW/ykg5Awk9tg9//ApZNI6a3OhlIp78i+4dFm03JkKpkl6xV3FeaKGcfVYPYAPUcCJRLRfGMxAhp3boRDCqug3ZxJLtufLxUgHs5BzbQqOjXY9hpsonpDyI4woLTE4FBtHmedbzUuplWUKkav3M16WBn3+by4VWVwLq0iqLxMpVazXTeuCbY+yDfaw+t5UvT3bfpHk= ajoly@2F7.42angouleme.fr diff --git a/ended/shell00/ex04/midLS b/ended/shell00/ex04/midLS new file mode 100644 index 0000000..f283a2f --- /dev/null +++ b/ended/shell00/ex04/midLS @@ -0,0 +1 @@ +ls -mFt diff --git a/ended/shell00/ex05/git_commit.sh b/ended/shell00/ex05/git_commit.sh new file mode 100644 index 0000000..4ca6982 --- /dev/null +++ b/ended/shell00/ex05/git_commit.sh @@ -0,0 +1 @@ +git log --pretty=format:"%H" -5 diff --git a/ended/shell00/ex06/git_ignore.sh b/ended/shell00/ex06/git_ignore.sh new file mode 100644 index 0000000..3b13e6b --- /dev/null +++ b/ended/shell00/ex06/git_ignore.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git ls-files --others --ignored --exclude-standard diff --git a/ended/shell00/ex07/b b/ended/shell00/ex07/b new file mode 100644 index 0000000..c2dab24 --- /dev/null +++ b/ended/shell00/ex07/b @@ -0,0 +1,11 @@ +Episode V, A NEW H0PE It is a period of civil war +Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. +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. + + +Pursued by the Empire's sinister agents, +Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie.. + + + + diff --git a/ended/shell00/ex08/clean b/ended/shell00/ex08/clean new file mode 100644 index 0000000..434b64c --- /dev/null +++ b/ended/shell00/ex08/clean @@ -0,0 +1 @@ +find .-type f -iname ~* -or -iname *# -print -delete diff --git a/ended/shell01/ex01/print_groups.sh b/ended/shell01/ex01/print_groups.sh new file mode 100644 index 0000000..f826aa3 --- /dev/null +++ b/ended/shell01/ex01/print_groups.sh @@ -0,0 +1 @@ +id -G -n $FT_USER | tr ' ' , | tr -d '\n' diff --git a/ended/shell01/ex02/find_sh.sh b/ended/shell01/ex02/find_sh.sh new file mode 100644 index 0000000..4028b6e --- /dev/null +++ b/ended/shell01/ex02/find_sh.sh @@ -0,0 +1 @@ +find . -type f -name "*.sh" -exec basename {} .sh \; diff --git a/ended/shell01/ex03/count_files.sh b/ended/shell01/ex03/count_files.sh new file mode 100644 index 0000000..ac16053 --- /dev/null +++ b/ended/shell01/ex03/count_files.sh @@ -0,0 +1 @@ +find . -type f,d | wc -l diff --git a/ended/shell01/ex04/MAC.sh b/ended/shell01/ex04/MAC.sh new file mode 100644 index 0000000..7537a27 --- /dev/null +++ b/ended/shell01/ex04/MAC.sh @@ -0,0 +1 @@ +ifconfig | grep -o '..:..:..:..:..:..' diff --git a/ended/shell01/ex05/_/_$_'MaRViN'_$_/_ b/ended/shell01/ex05/_/_$_'MaRViN'_$_/_ new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/ended/shell01/ex05/_/_$_'MaRViN'_$_/_ @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/ended/shell01/ex06/skip.sh b/ended/shell01/ex06/skip.sh new file mode 100644 index 0000000..06bd698 --- /dev/null +++ b/ended/shell01/ex06/skip.sh @@ -0,0 +1 @@ +ls -l | sed -n "1~2p" diff --git a/ended/shell01/ex07/r_dwssap.sh b/ended/shell01/ex07/r_dwssap.sh new file mode 100644 index 0000000..87b9f1d --- /dev/null +++ b/ended/shell01/ex07/r_dwssap.sh @@ -0,0 +1 @@ +cat /etc/passwd | awk -F : '{ print $1 }' | sed '1~2d' | rev | sort -r | sed -n ''$FT_LINE1','$FT_LINE2'p' | awk '{print $0 ", "}' | tr -d '\n' | awk '{ print substr( $0, 1, length($0)-2 ) }' | tr '\n' '.'