1
0

first commit

This commit is contained in:
Adam Joly
2023-08-03 23:16:27 +02:00
parent 7f3254f1c5
commit a80c4d61d7
133 changed files with 4293 additions and 0 deletions

View File

@ -0,0 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 10:32:16 by adjoly #+# #+# */
/* Updated: 2023/07/12 10:50:35 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_alphabet.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 11:08:23 by adjoly #+# #+# */
/* Updated: 2023/07/12 20:50:30 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_alphabet(void)
{
char i;
i = 'a';
while (i <= 'z')
{
write(1, &i, 1);
i++;
}
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_reverse_alphabet.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 11:08:23 by adjoly #+# #+# */
/* Updated: 2023/07/15 15:45:54 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_reverse_alphabet(void)
{
char i;
i = 'z';
while (i >= 'a')
{
write(1, &i, 1);
i--;
}
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_numbers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 20:36:08 by adjoly #+# #+# */
/* Updated: 2023/07/15 15:33:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_numbers(void)
{
char nbr;
nbr = '0';
while (nbr <= '9')
{
write(1, &nbr, 1);
nbr++;
}
}

View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_negative.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 20:51:36 by adjoly #+# #+# */
/* Updated: 2023/07/13 11:47:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_is_negative(int n)
{
if (n < 0)
write(1, "N", 1);
else
write(1, "P", 1);
}

View File

@ -0,0 +1,48 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 23:26:35 by adjoly #+# #+# */
/* Updated: 2023/07/13 11:45:59 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_virgule(char a, char b, char c)
{
if (!(a == '7' && b == '8' && c == '9'))
{
write(1, ",", 1);
write(1, " ", 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')
{
write(1, &a, 1);
write(1, &b, 1);
write(1, &c, 1);
ft_print_virgule(a, b, c);
c++;
}
b++;
}
a++;
}
}

View File

@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 11:13:23 by adjoly #+# #+# */
/* Updated: 2023/07/16 13:29:28 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_nbr(int a, int b)
{
char c;
char d;
char e;
char f;
c = a / 10 + 48;
d = a % 10 + 48;
e = b / 10 + 48;
f = b % 10 + 48;
write(1, &c, 1);
write(1, &d, 1);
write(1, " ", 1);
write(1, &e, 1);
write(1, &f, 1);
if (!(c == '9' && d == '8' && e == '9' && f == '9'))
write(1, ", ", 2);
}
void ft_print_comb2(void)
{
int a;
int b;
a = 0;
while (a <= 98)
{
b = a + 1;
while (b <= 99)
{
ft_print_nbr(a, b);
b++;
}
a++;
}
}

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 13:51:06 by adjoly #+# #+# */
/* Updated: 2023/07/16 13:26:07 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
if (nb == -214783648)
{
write(1, "-214783648", 10);
return ;
}
if (nb < 0)
{
write(1, "-", 1);
ft_putnbr(nb * -1);
}
else if (nb < 10)
write(1, &(char){nb + 48}, 1);
else
{
ft_putnbr(nb / 10);
write(1, &(char){nb % 10 + 48}, 1);
}
}

16
finish/C01/ex00/ft_ft.c Normal file
View File

@ -0,0 +1,16 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 18:51:05 by adjoly #+# #+# */
/* Updated: 2023/07/16 21:06:40 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_ft(int *nbr)
{
*nbr = 42;
}

View File

@ -0,0 +1,16 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ultimate_ft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 19:08:30 by adjoly #+# #+# */
/* Updated: 2023/07/13 19:09:22 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_ultimate_ft(int *********nbr)
{
*********nbr = 42;
}

20
finish/C01/ex02/ft_swap.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 19:20:17 by adjoly #+# #+# */
/* Updated: 2023/07/16 19:00:58 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_swap(int *a, int *b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}

View File

@ -0,0 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_div_mod.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 19:36:32 by adjoly #+# #+# */
/* Updated: 2023/07/13 19:40:32 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_div_mod(int a, int b, int *div, int *mod)
{
*div = a / b;
*mod = a % b;
}

View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ultimate_div_mod.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 10:03:47 by adjoly #+# #+# */
/* Updated: 2023/07/14 10:32:21 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_ultimate_div_mod(int *a, int *b)
{
int div;
int mod;
div = *a / *b;
mod = *a % *b;
*a = div;
*b = mod;
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 10:36:38 by adjoly #+# #+# */
/* Updated: 2023/07/14 18:35:37 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 18:37:42 by adjoly #+# #+# */
/* Updated: 2023/07/14 18:40:41 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}

View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_rev_int_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 18:49:16 by adjoly #+# #+# */
/* Updated: 2023/07/16 21:06:59 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
void ft_swap(int *a, int *b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
void ft_rev_int_tab(int *tab, int size)
{
int i;
i = 0;
while (i < size)
{
ft_swap(&tab[i], &tab[--size]);
i++;
}
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/15 16:49:13 by adjoly #+# #+# */
/* Updated: 2023/07/17 11:15:40 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcpy(char *dest, char *src)
{
int i;
i = 0;
while (src[i])
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
return (dest);
}

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/15 16:49:13 by adjoly #+# #+# */
/* Updated: 2023/07/17 22:41:12 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i])
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 14:06:22 by adjoly #+# #+# */
/* Updated: 2023/07/17 17:16:02 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int i;
i = 0;
while (str[i])
{
if ((str[i] < 65 || str[i] > 90) && (str[i] < 97 || str[i] > 122))
return (0);
i++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 14:06:22 by adjoly #+# #+# */
/* Updated: 2023/07/17 17:53:00 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] < '0' || str[i] > '9')
return (0);
i++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 14:06:22 by adjoly #+# #+# */
/* Updated: 2023/07/17 17:19:30 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] < 97 || str[i] > 122)
return (0);
i++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 14:06:22 by adjoly #+# #+# */
/* Updated: 2023/07/17 17:58:53 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] < 65 || str[i] > 90)
return (0);
i++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 14:06:22 by adjoly #+# #+# */
/* Updated: 2023/07/17 17:51:25 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] < 32 || str[i] == 127)
return (0);
i++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 17:50:51 by adjoly #+# #+# */
/* Updated: 2023/07/19 22:09:15 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] >= 97 && str[i] <= 122)
str[i] -= 32;
i++;
}
return (str);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 17:50:51 by adjoly #+# #+# */
/* Updated: 2023/07/20 09:37:24 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] >= 65 && str[i] <= 90)
str[i] = str[i] + 32;
i++;
}
return (str);
}

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 18:12:38 by adjoly #+# #+# */
/* Updated: 2023/07/18 21:24:58 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcapitalize(char *str)
{
int i;
i = 0;
if (str[i] >= 'a' && str[i] <= 'z')
str[i] -= 32;
i++;
while (str[i])
{
if ((str[i] >= 'a' && str[i] <= 'z')
&& !((str[i - 1] >= '0' && str[i - 1] <= '9')
|| (str[i - 1] >= 'a' && str[i - 1] <= 'z')
|| (str[i - 1] >= 'A' && str[i - 1] <= 'Z')))
str[i] -= 32;
else if (str[i] >= 'A' && str[i] <= 'Z'
&& ((str[i - 1] >= '0' && str[i - 1] <= '9')
|| (str[i - 1] >= 'a' && str[i - 1] <= 'z')
|| (str[i - 1] >= 'A' && str[i - 1] <= 'Z')))
str[i] += 32;
i++;
}
return (str);
}

View File

@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 13:39:08 by adjoly #+# #+# */
/* Updated: 2023/07/18 19:49:31 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
unsigned int i;
i = 0;
if (size == 0)
{
while (src[i])
i++;
return (i);
}
while (src[i] && i + 1 < size)
{
dest[i] = src[i];
i++;
}
while (i < size)
{
dest[i] = '\0';
i++;
}
i = 0;
while (src[i])
i++;
return (i);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 16:20:57 by adjoly #+# #+# */
/* Updated: 2023/07/25 13:06:36 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] || s2[i])
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
i++;
}
return (s1[i] - s2[i]);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 16:20:57 by adjoly #+# #+# */
/* Updated: 2023/07/25 13:07:01 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
unsigned int i;
i = 0;
while ((s1[i] || s2[i]) && i < n)
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
i++;
}
return (0);
}

View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 17:17:04 by adjoly #+# #+# */
/* Updated: 2023/07/18 17:33:22 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
char *ft_strcat(char *dest, char *src)
{
int size_dest;
unsigned int i;
i = 0;
size_dest = ft_strlen(dest);
while (src[i])
{
dest[size_dest + i] = src[i];
i++;
}
dest[size_dest + i] = '\0';
return (dest);
}

View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 17:17:04 by adjoly #+# #+# */
/* Updated: 2023/07/18 17:32:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
int size_dest;
unsigned int i;
i = 0;
size_dest = ft_strlen(dest);
while (src[i] && i < nb)
{
dest[size_dest + i] = src[i];
i++;
}
dest[size_dest + i] = '\0';
return (dest);
}

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/18 21:31:36 by adjoly #+# #+# */
/* Updated: 2023/07/20 22:14:23 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *to_find)
{
int i;
int j;
i = 0;
j = 0;
if (to_find[0] == '\0')
{
return (str);
}
while (str[i])
{
while (str[i + j] == to_find[j])
{
if (to_find[j + 1] == '\0')
return (&str[i]);
j++;
}
j = 0;
i++;
}
return (0);
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 08:44:17 by adjoly #+# #+# */
/* Updated: 2023/07/19 08:57:52 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 08:58:22 by adjoly #+# #+# */
/* Updated: 2023/07/19 09:02:13 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}

View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/13 13:51:06 by adjoly #+# #+# */
/* Updated: 2023/07/25 12:57:21 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
unsigned int nbr;
if (nb < 0)
{
write(1, "-", 1);
nbr = -nb;
}
else
nbr = nb;
if (nbr < 10)
write(1, &(char){nbr + 48}, 1);
else
{
ft_putnbr(nbr / 10);
write(1, &(char){nbr % 10 + 48}, 1);
}
}

37
finish/C04/ex03/ft_atoi.c Normal file
View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 09:27:06 by adjoly #+# #+# */
/* Updated: 2023/07/26 09:56:29 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_atoi(char *str)
{
int i;
int neg;
int result;
i = 0;
neg = 1;
result = 0;
while (str[i] == ' ' || (str[i] >= 9 && str[i] <= 13))
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++;
}
result *= neg;
return (result);
}

View File

@ -0,0 +1,70 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/19 14:25:29 by adjoly #+# #+# */
/* Updated: 2023/07/25 09:20:02 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
int ft_checkbase(char *base)
{
int i;
int j;
i = 0;
if (ft_strlen(base) <= 1)
return (1);
while (base[i])
{
if (base[i] == '-' || base[i] == '+')
return (1);
j = i + 1;
while (base[j])
{
if (base[i] == base[j])
return (1);
j++;
}
i++;
}
return (0);
}
void ft_putnbr_base(int nbr, char *base)
{
unsigned int len;
unsigned int y;
if (ft_checkbase(base) == 1)
return ;
len = ft_strlen(base);
if (nbr < 0)
{
write(1, "-", 1);
y = -nbr;
}
else
y = nbr;
if (y < len)
write(1, &(char){base[y]}, 1);
else
{
ft_putnbr_base(y / len, base);
write(1, &(char){base[y % len]}, 1);
}
}

View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_program_name.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/24 09:18:20 by adjoly #+# #+# */
/* Updated: 2023/07/24 09:22:02 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int main(int ac, char **av)
{
int i;
i = 0;
(void)ac;
while (av[0][i])
{
write(1, &av[0][i], 1);
i++;
}
}

View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_params.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/24 09:26:14 by adjoly #+# #+# */
/* Updated: 2023/07/24 09:40:30 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int main(int ac, char **av)
{
int i;
int j;
(void)ac;
i = 1;
j = 0;
while (av[i])
{
j = 0;
while (av[i][j])
{
write(1, &av[i][j], 1);
j++;
}
write(1, "\n", 1);
i++;
}
}

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_rev_params.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/24 09:38:41 by adjoly #+# #+# */
/* Updated: 2023/07/27 09:49:32 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int main(int ac, char **av)
{
int i;
int j;
i = 0;
(void)ac;
while (av[i])
i++;
while (i > 1)
{
j = 0;
i--;
while (av[i][j])
{
write(1, &av[i][j], 1);
j++;
}
write(1, "\n", 1);
}
}

View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/12 11:59:45 by ttrave #+# #+# */
/* Updated: 2023/07/15 09:59:04 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

19
finish/rush00/ex00/main.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/15 10:00:20 by ttrave #+# #+# */
/* Updated: 2023/07/15 10:39:38 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void rush(int x, int y);
int main(void)
{
rush(25, 17);
return (0);
}

View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 21:13:37 by ttrave #+# #+# */
/* Updated: 2023/07/16 11:30:51 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void rush(int x, int y)
{
int w;
int h;
w = 1;
h = 1;
while (y > 0 && h <= y)
{
while (x > 0 && w <= x)
{
if (((h == 1 || h == y) && w == 1)
|| ((h == 1 || h == y) && w == x))
ft_putchar('o');
else if (w == x || w == 1)
ft_putchar('|');
else if (h == 1 || h == y)
ft_putchar('-');
else
ft_putchar(' ');
w++;
}
ft_putchar('\n');
w = 1;
h++;
}
}

View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush01.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 21:13:37 by ttrave #+# #+# */
/* Updated: 2023/07/16 11:31:22 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void rush(int x, int y)
{
int w;
int h;
w = 1;
h = 1;
while (y > 0 && h <= y)
{
while (x > 0 && w <= x)
{
if ((w == 1 && h == 1) || (w == x && h == y))
ft_putchar('/');
else if ((w == x && h == 1) || (w == 1 && h == y))
ft_putchar('\\');
else if (w == x || w == 1 || h == 1 || h == y)
ft_putchar('*');
else
ft_putchar(' ');
w++;
}
ft_putchar('\n');
w = 1;
h++;
}
}

View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush02.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 21:13:37 by ttrave #+# #+# */
/* Updated: 2023/07/16 11:32:34 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void rush(int x, int y)
{
int w;
int h;
w = 1;
h = 1;
while (y > 0 && h <= y)
{
while (x > 0 && w <= x)
{
if (h == 1 && (w == 1 || w == x))
ft_putchar('A');
else if (h == y && (w == 1 || w == x))
ft_putchar('C');
else if (w == x || w == 1 || h == 1 || h == y)
ft_putchar('B');
else
ft_putchar(' ');
w++;
}
ft_putchar('\n');
w = 1;
h++;
}
}

View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush03.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 21:13:37 by ttrave #+# #+# */
/* Updated: 2023/07/16 11:33:12 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void rush(int x, int y)
{
int w;
int h;
w = 1;
h = 1;
while (y > 0 && h <= y)
{
while (x > 0 && w <= x)
{
if (w == 1 && (h == 1 || h == y))
ft_putchar('A');
else if (w == x && (h == 1 || h == y))
ft_putchar('C');
else if (w == x || w == 1 || h == 1 || h == y)
ft_putchar('B');
else
ft_putchar(' ');
w++;
}
ft_putchar('\n');
w = 1;
h++;
}
}

View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush04.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 21:13:37 by ttrave #+# #+# */
/* Updated: 2023/07/16 11:33:48 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
void rush(int x, int y)
{
int w;
int h;
w = 1;
h = 1;
while (y > 0 && h <= y)
{
while (x > 0 && w <= x)
{
if ((w == 1 && h == 1) || (w == x && h == y))
ft_putchar('A');
else if ((w == x && h == 1) || (w == 1 && h == y))
ft_putchar('C');
else if (w == x || w == 1 || h == 1 || h == y)
ft_putchar('B');
else
ft_putchar(' ');
w++;
}
ft_putchar('\n');
w = 1;
h++;
}
}

View File

@ -0,0 +1,108 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* bruteforce.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmikola <jmikola@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 12:00:11 by psalame #+# #+# */
/* Updated: 2023/07/23 12:43:04 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
int get_area_size(void);
int ft_test_possibility(int **tab, int i);
int verif_non_double(int i, int **tab);
int verif_col_down(int i, int **tab);
int verif_col_up(int i, int **tab);
int verif_row_right(int i, int **tab);
int verif_row_left(int i, int **tab);
int **get_row(void);
int **get_col(void);
int verif_all_row(int i, int **tab)
{
int row_left;
int row_right;
int area_size;
area_size = get_area_size();
row_left = verif_row_left(i, tab);
row_right = verif_row_right(i, tab);
if (((i % area_size) == area_size - 1))
{
if (row_left != get_row()[i / area_size][0]
|| row_right != get_row()[i / area_size][1])
return (0);
}
else if (row_left > get_row()[i / area_size][0])
return (0);
return (1);
}
int verif_all_col(int i, int **tab)
{
int col_up;
int col_down;
int area_size;
area_size = get_area_size();
col_up = verif_col_up(i, tab);
col_down = verif_col_down(i, tab);
if (((i / area_size) == area_size - 1))
{
if (col_up != get_col()[i % area_size][0]
|| col_down != get_col()[i % area_size][1])
return (0);
}
else if (col_up > get_col()[i % area_size][0])
return (0);
return (1);
}
int verif(int i, int **tab)
{
if (!verif_non_double(i, tab))
return (0);
return (verif_all_row(i, tab) && verif_all_col(i, tab));
}
int is_possibility_valid(int **tab, int i)
{
int area_size;
area_size = get_area_size();
if (i == area_size * area_size - 1)
return (1);
else
return (ft_test_possibility(tab, i + 1));
}
int ft_test_possibility(int **tab, int i)
{
int area_size;
int height;
area_size = get_area_size();
if (tab[i / area_size][i % area_size] == 0)
{
height = 0;
while (++height <= area_size)
{
tab[i / area_size][i % area_size] = height;
if (verif(i, tab))
{
if (is_possibility_valid(tab, i))
return (1);
}
}
tab[i / area_size][i % area_size] = 0;
return (0);
}
else
{
if (!verif(i, tab))
return (0);
return (is_possibility_valid(tab, i));
}
}

View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_free_tabtab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psalame <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 14:18:27 by psalame #+# #+# */
/* Updated: 2023/07/22 16:25:32 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
void ft_free_tabtab(int **tab, int size)
{
int i;
i = 0;
while (i < size)
{
free(tab[i]);
i++;
}
free(tab);
}

View File

@ -0,0 +1,94 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_tables.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psalame <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 19:12:44 by psalame #+# #+# */
/* Updated: 2023/07/23 17:44:52 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int get_area_size(void);
int **get_row_args(char **argv)
{
int i_row;
int tab_index;
int **row;
int s;
s = get_area_size();
row = malloc(s * sizeof(int *));
if (row == NULL)
return (NULL);
i_row = s * 4;
tab_index = 0;
while (i_row < (s * 6 - 1))
{
if (argv[1][i_row] != ' ')
{
row[tab_index] = malloc(2 * sizeof(int));
row[tab_index][0] = argv[1][i_row] - '0';
row[tab_index][1] = argv[1][i_row + s * 2] - '0';
tab_index ++;
}
i_row ++;
}
return (row);
}
int **get_col_args(char **argv)
{
int i_col;
int tab_index;
int **col;
int s;
s = get_area_size();
col = (int **) malloc(s * sizeof(int *));
if (col == NULL)
return (NULL);
i_col = 0;
tab_index = 0;
while (i_col < (s * 2 - 1))
{
if (argv[1][i_col] != ' ')
{
col[tab_index] = malloc(2 * sizeof(int));
col[tab_index][0] = argv[1][i_col] - '0';
col[tab_index][1] = argv[1][i_col + s * 2] - '0';
tab_index++;
}
i_col ++;
}
return (col);
}
int **init_res(void)
{
int i;
int j;
int **res;
res = malloc(get_area_size() * sizeof(int *));
if (res == NULL)
return (NULL);
i = 0;
j = 0;
while (i < get_area_size())
{
res[i] = malloc(get_area_size() * sizeof(int));
j = 0;
while (j < get_area_size())
{
res[i][j] = 0;
j++;
}
i++;
}
return (res);
}

View File

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* is_args_valid.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psalame <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 13:31:00 by psalame #+# #+# */
/* Updated: 2023/07/23 11:19:18 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
int is_args_valid(int argc, char **argv)
{
int i;
int area_size;
if (argc != 2)
return (0);
area_size = (ft_strlen(argv[1]) + 1) / 2 / 2 / 2;
if (area_size < 2 || (ft_strlen(argv[1]) + 1) % area_size != 0)
return (0);
i = 0;
while (argv[1][i] && area_size != 0)
{
if (i % 2 == 0)
{
if (argv[1][i] < '1' || argv[1][i] > '0' + area_size)
area_size = 0;
}
else
if (argv[1][i] != ' ')
area_size = 0;
i++;
}
return (area_size);
}

70
finish/rush01/ex00/main.c Normal file
View File

@ -0,0 +1,70 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ale-gal <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 12:32:28 by ale-gal #+# #+# */
/* Updated: 2023/07/23 17:45:59 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int get_area_size(void);
int **get_col_args(char **argv);
int **get_row_args(char **argv);
void ft_free_tabtab(int **tab, int size);
void ft_print_double_tab(int **tab, int size);
int **ft_place_sure(int **row, int **col, int **result);
int is_args_valid(int argc, char **argv);
int ft_test_possibility(int **tab, int i);
int **init_res(void);
int **g_col;
int **g_row;
int g_area_size;
int **get_col(void)
{
return (g_col);
}
int **get_row(void)
{
return (g_row);
}
int main(int argc, char **argv)
{
int **res;
g_area_size = is_args_valid(argc, argv);
if (g_area_size == 0)
{
write(1, "Error\n", 6);
return (0);
}
g_col = get_col_args(argv);
g_row = get_row_args(argv);
res = init_res();
if (g_col == NULL || g_row == NULL || res == NULL)
{
write(1, "Error\n", 6);
return (0);
}
ft_place_sure(g_row, g_col, res);
if (ft_test_possibility(res, 0))
ft_print_double_tab(res, get_area_size());
else
write(1, "Error\n", 6);
ft_free_tabtab(res, get_area_size());
ft_free_tabtab(g_col, get_area_size());
ft_free_tabtab(g_row, get_area_size());
return (0);
}
int get_area_size(void)
{
return (g_area_size);
}

View File

@ -0,0 +1,115 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* place_sure.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 11:37:10 by adjoly #+# #+# */
/* Updated: 2023/07/23 11:11:18 by psalame ### ########.fr */
/* */
/* ************************************************************************** */
int get_area_size(void);
void con_col(int **result, int i, int j, int **col)
{
int k;
k = 0;
if (col[i][j] == 1)
{
if (j == 1)
result[get_area_size() - 1][i] = get_area_size();
else
result[0][i] = get_area_size();
}
else if (col[i][j] == get_area_size())
{
if (j == 1)
{
k = get_area_size() + 1;
while (--k > 0)
result[k - 1][i] = (get_area_size() - k + 1);
}
else
{
while (++k <= get_area_size())
result[k - 1][i] = k;
}
}
}
void con_row(int **result, int i, int j, int **row)
{
int k;
k = 0;
if (row[i][j] == 1)
{
if (j == 1)
result[i][get_area_size() - 1] = get_area_size();
else
result[i][0] = get_area_size();
}
else if (row[i][j] == get_area_size())
{
if (j == 1)
{
k = get_area_size();
while (--k > 0)
result[i][k - 1] = (get_area_size() - k + 1);
}
else
{
while (++k <= get_area_size())
result[i][k - 1] = k;
}
}
}
void place_col(int size, int **col, int **result)
{
int i;
int j;
i = 0;
while (i < size)
{
j = 0;
while (j < 2)
{
con_col(result, i, j, col);
j++;
}
i++;
}
}
void place_row(int size, int **row, int **result)
{
int i;
int j;
i = 0;
while (i < size)
{
j = 0;
while (j < 2)
{
con_row(result, i, j, row);
j++;
}
i++;
}
}
int **ft_place_sure(int **row, int **col, int **result)
{
int size;
size = get_area_size();
place_row(size, row, result);
place_col(size, col, result);
return (result);
}

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_double_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ale-gal <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 11:42:20 by ale-gal #+# #+# */
/* Updated: 2023/07/22 16:51:52 by ale-gal ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_double_tab(int **tab, int size)
{
int i_x;
int i_y;
char chr;
i_y = 0;
while (i_y < size)
{
i_x = 0;
while (i_x < size)
{
chr = '0' + tab[i_y][i_x];
write(1, &chr, 1);
if (i_x != size - 1)
write(1, " ", 1);
i_x++;
}
write(1, "\n", 1);
i_y++;
}
}

128
finish/rush01/ex00/verif.c Normal file
View File

@ -0,0 +1,128 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* verif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmikola <jmikola@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/22 13:01:37 by jmikola #+# #+# */
/* Updated: 2023/07/23 10:53:36 by jmikola ### ########.fr */
/* */
/* ************************************************************************** */
int get_area_size(void);
int verif_row_left(int i, int **tab)
{
int val_row_left;
int v_max;
int j;
int area_size;
j = 0;
val_row_left = 0;
v_max = 0;
area_size = get_area_size();
while (j < area_size)
{
if (tab[i / area_size][j] > v_max)
{
val_row_left++;
v_max = tab[i / area_size][j];
}
j++;
}
return (val_row_left);
}
int verif_row_right(int i, int **tab)
{
int val_row_right;
int v_max;
int j;
int area_size;
area_size = get_area_size();
j = area_size - 1;
v_max = 0;
val_row_right = 0;
while (j >= 0)
{
if (tab[i / area_size][j] > v_max)
{
val_row_right++;
v_max = tab[i / area_size][j];
}
j--;
}
return (val_row_right);
}
int verif_col_up(int i, int **tab)
{
int val_col_up;
int v_max;
int j;
int area_size;
j = 0;
v_max = 0;
val_col_up = 0;
area_size = get_area_size();
while (j < area_size)
{
if (tab[j][i % area_size] > v_max)
{
val_col_up++;
v_max = tab[j][i % area_size];
}
j++;
}
return (val_col_up);
}
int verif_col_down(int i, int **tab)
{
int val_col_down;
int v_max;
int j;
int area_size;
area_size = get_area_size();
j = area_size - 1;
v_max = 0;
val_col_down = 0;
while (j >= 0)
{
if (tab[j][i % area_size] > v_max)
{
val_col_down++;
v_max = tab[j][i % area_size];
}
j--;
}
return (val_col_down);
}
int verif_non_double(int i, int **tab)
{
int j;
int area_size;
j = 0;
area_size = get_area_size();
while (j < i % area_size)
{
if (tab[i / area_size][j] == tab[i / area_size][i % area_size])
return (0);
j++;
}
j = 0;
while (j < i / area_size)
{
if (tab[j][i % area_size] == tab[i / area_size][i % area_size])
return (0);
j++;
}
return (1);
}

View File

@ -0,0 +1,46 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
# Updated: 2023/07/30 22:41:49 by tomoron ### ########.fr #
# #
# **************************************************************************** #
NAME = rush-02
CC = gcc
SRCS = algo.c \
algo2.c \
lib2.c \
lib.c \
main.c \
parse2.c \
parse.c \
special_tens.c
OBJS = $(SRCS:.c=.o)
FLAGS = -Wall -Wextra -Werror
$(NAME): $(OBJS)
$(CC) $(FLAGS) -o $(NAME) $(OBJS)
.c.o:
$(CC) $(FLAGS) -c $< -o $@
all: $(NAME)
clean:
rm -f $(OBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: clean all re fclean

127
finish/rush02/ex00/algo.c Normal file
View File

@ -0,0 +1,127 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* algo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 17:23:56 by ttrave #+# #+# */
/* Updated: 2023/07/30 22:35:56 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
void ft_prep_algo(char **dict, char *nbr)
{
t_ulli len;
char **spec_tens;
len = ft_strlen(nbr);
spec_tens = ft_fill_spec_tens(dict);
if (spec_tens == NULL)
{
ft_putstr("Error\n");
return ;
}
ft_nbr_to_letters(dict, nbr, spec_tens, len);
}
void ft_nbr_to_letters(char **dict, char *nbr, char **spec_tens, t_ulli l)
{
t_ulli v;
t_ulli *i;
t_ulli group;
char *last_group_marker;
char *nb;
group = l / 3;
i = &v;
*i = l;
while (*i > 0)
{
if (*i % 3 == 0)
ft_print_hundreds(dict, nbr, i, l);
else if (*i % 3 == 2)
{
nb = ft_cat(nbr[l - *i], nbr[l - *i + 1]);
if (nb == NULL)
return ;
ft_print_tens(dict, spec_tens, nb, i);
}
else if (*i % 3 == 1)
ft_print_units(dict, nbr[l - *i], i);
last_group_marker = ft_print_group_marker(dict, i);
if (last_group_marker == NULL)
{
ft_free_arr_arr(spec_tens);
ft_putstr("Error\n");
return ;
}
if (*i % 3 == 1 && *i > 1)
{
ft_putchar(',');
group--;
}
}
ft_putchar('\n');
free(spec_tens);
}
void ft_print_units(char **dict, char unit, t_ulli *i)
{
ft_print_next(ft_strndup(&unit, 1), dict);
if (*i > 0)
ft_putchar(' ');
(*i)--;
}
void ft_print_hundreds(char **dict, char *nbr, t_ulli *i, t_ulli len)
{
ft_print_next(ft_strndup(&nbr[len - *i], 1), dict);
ft_putchar(' ');
ft_print_next("100", dict);
if (nbr[len - *i + 1] != '0' || nbr[len - *i + 2] != '0')
ft_putstr(" and ");
(*i)--;
}
void ft_print_tens(char **dict, char **spec_tens, char *nb, t_ulli *i)
{
if (ft_is_spec_ten(spec_tens, nb) == 0)
{
ft_print_next(nb, dict);
(*i) -= 2;
if (*i > 2)
ft_putchar(' ');
}
else
{
ft_print_next(nb, dict);
ft_putchar('-');
(*i)--;
}
}
char *ft_print_group_marker(char **dict, t_ulli *len)
{
char *group_marker;
t_ulli i;
i = 1;
if (*len % 3 != 1 || *len < 4)
return ("1");
group_marker = malloc((*len + 1) * sizeof(char));
if (group_marker == NULL)
return (group_marker);
group_marker[*len] = '\0';
group_marker[0] = '1';
while (group_marker[i])
{
group_marker[i] = '0';
i++;
}
ft_print_next(group_marker, dict);
free(group_marker);
return ("1");
}

View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* algo2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/30 20:14:14 by ttrave #+# #+# */
/* Updated: 2023/07/30 20:28:15 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
void ft_print_next(char *str, char **dict)
{
while (*dict != NULL)
{
if (ft_strcmp(str, *dict) == 0)
{
dict++;
ft_putstr(*dict);
return ;
}
dict += 2;
}
}

View File

@ -0,0 +1,29 @@
0: zéro
1: un
2: deux
3: trois
4: quatre
5: cinq
6: six
7: sept
8: huit
9: neuf
10: dix
11: onze
12: douze
13: treize
14: quatorze
15: quinze
16: seize
20: vingt
30: trente
40: quarante
50: cinquante
60: soixante
70: septante
80: huitante
90: nonante
100: cent
1000: mille
1000000: million
1000000000: milliard

View File

@ -0,0 +1,32 @@
19: nineteen
0: zero
1: one
2: two
3: three
18: eighteen
4: four
5: five
6: six
7: seven
8: eight
9: nine
10: ten
11: eleven
12: twelve
13: thirteen
14: fourteen
15: fifteen
16: sixteen
20: twenty
30: thirty
40: forty
50: fifty
60: sixty
70: seventy
80: eighty
90: ninety
100: hundred
1000: thousand
1000000: million
1000000000: billion
17: seventeen

View File

@ -0,0 +1,59 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* header.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/30 16:51:35 by adjoly #+# #+# */
/* Updated: 2023/07/30 22:36:51 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef HEADER_H
# define HEADER_H
# include <stdlib.h>
# include <fcntl.h>
# include <unistd.h>
typedef unsigned long long int t_ulli;
void ft_prep_algo(char **dict, char *nbr);
void ft_nbr_to_letters(char **dict, char *nbr, char **spec_tens, t_ulli l);
void ft_print_units(char **dict, char unit, t_ulli *len);
void ft_print_hundreds(char **dict, char *nbr, t_ulli *i, t_ulli len);
void ft_print_tens(char **dict, char **spec_tens, char *nb, t_ulli *i);
char *ft_print_group_marker(char **dict, t_ulli *i);
int ft_marker_and_comma(char **dict, t_ulli i, t_ulli group);
void ft_print_next(char *str, char **dict);
char *ft_parse_nbr(char *nbr);
int ft_calc_part_len(char *str, int mode);
int ft_copy_nb(char *res, char *file, int k);
int ft_copy_value(char *res, char *file, int k);
int ft_fill_dict(char **res, char *file, int i, int k);
char **ft_parse_dict(char *filename);
char *ft_read_file(char *filename);
int ft_count_parts(char *file);
int ft_error(char **res, char *file, int i);
char **ft_malloc_spec_tens(char **dict);
char **ft_fill_spec_tens(char **dict);
int ft_is_spec_ten(char **spec_tens, char *nb);
t_ulli ft_strlen(char *str);
void ft_putchar(char charac);
void ft_putstr(char *str);
int ft_strcmp(char *s1, char *s2);
char *ft_strndup(char *src, t_ulli n);
void ft_free_n_arr_arr(char **arr, t_ulli n);
void ft_free_arr_arr(char **arr);
int ft_number_is_printable(char *number, char **dict);
char *ft_cat(char ten, char unit);
#endif

75
finish/rush02/ex00/lib.c Normal file
View File

@ -0,0 +1,75 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 12:52:50 by adjoly #+# #+# */
/* Updated: 2023/07/30 20:02:25 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
t_ulli ft_strlen(char *str)
{
t_ulli i;
i = 0;
while (str[i])
i++;
return (i);
}
void ft_putchar(char charac)
{
write(1, &charac, 1);
}
void ft_putstr(char *str)
{
t_ulli i;
i = 0;
while (str[i])
{
ft_putchar(str[i]);
i++;
}
}
int ft_strcmp(char *s1, char *s2)
{
t_ulli i;
i = 0;
while (s1[i] || s2[i])
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
i++;
}
return (s1[i] - s2[i]);
}
char *ft_strndup(char *src, t_ulli n)
{
char *res;
t_ulli len;
t_ulli i;
len = ft_strlen(src);
i = 0;
res = malloc((len + 1) + sizeof(char));
if (res)
{
while (src[i] && i < n)
{
res[i] = src[i];
i++;
}
res[i] = 0;
}
return (res);
}

70
finish/rush02/ex00/lib2.c Normal file
View File

@ -0,0 +1,70 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/30 16:46:55 by ttrave #+# #+# */
/* Updated: 2023/07/30 20:41:52 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
void ft_free_n_arr_arr(char **arr, t_ulli n)
{
t_ulli i;
i = 0;
while (i < n)
{
free(arr[i]);
i++;
}
free(arr);
}
void ft_free_arr_arr(char **arr)
{
t_ulli i;
i = 0;
while (arr[i])
{
free(arr[i]);
i++;
}
free(arr);
}
int ft_number_is_printable(char *number, char **dict)
{
t_ulli i;
t_ulli len;
len = 0;
i = 0;
while (dict[i])
{
if (len < ft_strlen(dict[i]))
len = ft_strlen(dict[i]);
i += 2;
}
if (ft_strlen(number) > len + 2)
return (0);
return (1);
}
char *ft_cat(char ten, char unit)
{
char *res;
res = malloc(3 * sizeof(int));
if (!res)
return (0);
res[0] = ten;
res[1] = unit;
res[2] = 0;
return (res);
}

View File

@ -0,0 +1,62 @@
0: zero
1: one
2: two
3: three
4: four
5: five
6: six
7: seven
8: eight
9: nine
10: ten
11: eleven
12: twelve
13: thirteen
14: fourteen
15: fifteen
16: sixteen
17: seventeen
18: eighteen
19: nineteen
20: twenty
30: thirty
40: forty
50: fifty
60: sixty
70: seventy
80: eighty
90: ninety
100: hundred
1000: thousand
1000000: million
1000000000: billion
1000000000000: quadrillion
1000000000000000: quintrillion
1000000000000000000: sextillion
1000000000000000000000: septillion
1000000000000000000000000: octillion
1000000000000000000000000000: nonillion
1000000000000000000000000000000: decillion
1000000000000000000000000000000000: undecillion
1000000000000000000000000000000000000: duodecillion
1000000000000000000000000000000000000000: tredecillion
1000000000000000000000000000000000000000000: quatuordecillion
1000000000000000000000000000000000000000000000: quindecillion
1000000000000000000000000000000000000000000000000: sexdecillion
1000000000000000000000000000000000000000000000000000: septemdecillion
1000000000000000000000000000000000000000000000000000000: octodecillion
1000000000000000000000000000000000000000000000000000000000: novemdecillion
1000000000000000000000000000000000000000000000000000000000000: vigintillion
1000000000000000000000000000000000000000000000000000000000000000: unvigintillion
1000000000000000000000000000000000000000000000000000000000000000000: duovigintillion
1000000000000000000000000000000000000000000000000000000000000000000000: trevigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000: quatuorvigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000: quinvigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000: sexvigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000: septvigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000: octovigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: nonvigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: trigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: untrigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: duotrigintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: googol

118
finish/rush02/ex00/main.c Normal file
View File

@ -0,0 +1,118 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/30 12:35:34 by tomoron #+# #+# */
/* Updated: 2023/07/30 22:40:03 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
char *ft_parse_nbr(char *nbr)
{
char *res;
int i;
int j;
int len;
int sign;
i = 0;
sign = 1;
while (nbr[i] == '-' || nbr[i] == '+')
{
if (nbr[i] == '-')
sign *= -1;
nbr++;
}
len = 0;
while (nbr[i + len] >= '0' && nbr[i + len] <= '9')
len ++;
res = malloc((len + 1) * sizeof(char));
j = 0;
while (res && nbr[i] >= '0' && nbr[i] <= '9')
res[j++] = nbr[i++];
if (res)
res[j] = 0;
return (res);
}
void ft_pre_prep_algo(char *filename, char *nbr)
{
char **dict;
char *number;
dict = ft_parse_dict(filename);
if (!dict)
{
ft_putstr("Dict Error\n");
return ;
}
number = ft_parse_nbr(nbr);
if (number && !ft_number_is_printable(number, dict))
{
ft_free_arr_arr(dict);
if (number)
free(number);
return ;
}
ft_prep_algo(dict, number);
ft_free_arr_arr(dict);
free(number);
}
char *ft_realloc(char c, char *str)
{
t_ulli len;
t_ulli i;
char *new_str;
len = ft_strlen(str);
i = 0;
new_str = malloc((len + 2) * sizeof(char));
while (i < len)
{
new_str[i] = str[i];
i++;
}
new_str[i] = c;
new_str[i + 1] = 0;
free(str);
return (new_str);
}
void stdin_mode(char *filename)
{
char c;
char *str;
str = malloc(1 * sizeof(char));
str[0] = 0;
while (read(0, &c, 1))
{
if (c != '\n')
str = ft_realloc(c, str);
else
{
ft_pre_prep_algo(filename, str);
free(str);
str = malloc(1 * sizeof(char));
str[0] = 0;
}
}
}
int main(int argc, char **argv)
{
char *filename;
filename = "en.dict";
if (argc <= 1)
stdin_mode(filename);
else if (argc == 2)
ft_pre_prep_algo(filename, argv[1]);
else if (argc == 3)
ft_pre_prep_algo(argv[1], argv[2]);
}

153
finish/rush02/ex00/parse.c Normal file
View File

@ -0,0 +1,153 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 11:14:01 by tomoron #+# #+# */
/* Updated: 2023/07/30 20:22:03 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
int ft_calc_part_len(char *str, int mode)
{
int res;
res = 0;
if (mode == 1)
{
while (*str >= '0' && *str <= '9')
{
res++;
str++;
}
}
if (mode == 2)
{
while (*str >= 32 && *str <= 126)
{
res++;
while (*str == ' ')
str++;
str++;
}
}
return (res + 1);
}
int ft_copy_nb(char *res, char *file, int k)
{
int j;
j = 0;
while (file[k] >= '0' && file[k] <= '9')
{
res[j] = file[k];
k++;
j++;
}
res[j] = 0;
while (file[k] == ' ')
k++;
if (file[k] != ':' || j == 0)
return (0);
k++;
while (file[k] == ' ')
k++;
return (k);
}
int ft_copy_value(char *res, char *file, int k)
{
int j;
j = 0;
while (file[k] >= 32 && file[k] <= 126)
{
res[j] = file[k];
if (file[k] == ' ')
{
while (file[k] == ' ')
k++;
if (file[k] == '\0' || file[k] == '\n')
j--;
k--;
}
k++;
j++;
}
res[j] = 0;
if ((file[k] != '\n' && file[k] != '\0') || j == 0)
return (0);
while (file[k] == '\n')
k++;
return (k);
}
int ft_fill_dict(char **res, char *file, int i, int k)
{
while (file[k] == ' ')
k++;
res[i] = malloc(ft_calc_part_len(file + k, 1) * sizeof(char));
if (!res[i])
return (ft_error(res, file, i - 1));
k = ft_copy_nb(res[i], file, k);
if (!k)
return (ft_error(res, file, i));
i++;
res[i] = malloc(ft_calc_part_len(file + k, 2) * sizeof(char));
if (!res[i])
return (ft_error(res, file, i - 1));
k = ft_copy_value(res[i], file, k);
if (!k)
return (ft_error(res, file, i));
return (k);
}
char **ft_parse_dict(char *filename)
{
char **res;
char *file;
int i;
int k;
file = ft_read_file(filename);
if (!file)
return (0);
res = malloc(ft_count_parts(file) * sizeof(char *));
if (!res)
return (0);
k = 0;
while (file[k] == '\n')
k++;
i = 0;
while (file[k])
{
k = ft_fill_dict(res, file, i, k);
if (!k)
return (0);
i += 2;
}
res[i] = 0;
free(file);
return (res);
}
/*int main(void)
{
char **test;
int i;
i = 0;
test = ft_parse_dict("lol.dict");
while (test && test[i])
{
printf("%s, ", test[i]);
fflush(stdout);
i++;
}
return (0);
}*/

View File

@ -0,0 +1,79 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 17:38:13 by tomoron #+# #+# */
/* Updated: 2023/07/30 22:09:51 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
char *ft_read_file(char *filename)
{
char c;
int file;
int len;
char *res;
int i;
i = 0;
file = open(filename, O_RDONLY);
len = 0;
if (file == -1)
return (0);
while (read(file, &c, 1))
len++;
close(file);
res = malloc((len + 1) * sizeof(char));
file = open(filename, O_RDONLY);
if (file == -1 || !res)
return (0);
while (read(file, &c, 1))
res[i++] = c;
res[i] = 0;
close(file);
return (res);
}
int ft_count_parts(char *file)
{
int res;
int sem_found;
res = 0;
while (*file == '\n')
file++;
while (*file)
{
sem_found = 0;
while (*file != '\n' && *file)
{
file++;
if (!sem_found && *file == ':')
{
sem_found = 1;
res++;
}
}
res++;
while (*file == '\n')
file++;
}
return (res + 1);
}
int ft_error(char **res, char *file, int i)
{
while (i >= 0)
{
free(res[i]);
i--;
}
free(res);
free(file);
return (0);
}

View File

@ -0,0 +1,77 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* special_tens.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttrave <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 12:29:42 by ttrave #+# #+# */
/* Updated: 2023/07/30 21:52:07 by ttrave ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
char **ft_malloc_spec_tens(char **dict)
{
char **spec_tens;
t_ulli i;
t_ulli size;
size = 0;
i = 0;
while (dict[i])
{
if (dict[i][0] == '1' && dict[i][1] >= '0' && dict[i][1] <= '9'
&& ft_strlen(dict[i]) == 2)
size++;
i++;
}
spec_tens = malloc((size + 1) * sizeof(char *));
if (spec_tens != NULL)
spec_tens[size] = NULL;
return (spec_tens);
}
char **ft_fill_spec_tens(char **dict)
{
char **spec_tens;
t_ulli i;
t_ulli j;
i = -1;
j = 0;
spec_tens = ft_malloc_spec_tens(dict);
if (spec_tens == NULL)
return (spec_tens);
while (dict[++i])
{
if (dict[i][0] == '1' && dict[i][1] >= '0' && dict[i][1] <= '9'
&& ft_strlen(dict[i]) == 2)
{
spec_tens[j] = malloc(2 * sizeof(char));
if (spec_tens[j] == NULL)
{
ft_free_n_arr_arr(spec_tens, j + 1);
return (NULL);
}
spec_tens[j] = dict[i];
j++;
}
}
return (spec_tens);
}
int ft_is_spec_ten(char **spec_tens, char *nb)
{
t_ulli i;
i = 0;
while (spec_tens[i])
{
if (ft_strcmp(spec_tens[i], nb) == 0)
return (0);
i++;
}
return (1);
}

1
finish/shell00/ex00/z Normal file
View File

@ -0,0 +1 @@
Z

Binary file not shown.

Binary file not shown.

1
finish/shell00/ex02/test1 Executable file
View File

@ -0,0 +1 @@
000

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1 @@

1
finish/shell00/ex02/test6 Symbolic link
View File

@ -0,0 +1 @@
test0

View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDER2GObbWsRTVVskOYu+R4K1EOV08BRBXo31ppEmr50/g/09ehcRCqiMeZ15wPbbh/itEU1/t0OmBSNiVD+SQ4MSOZcB/cjUKOiTtUaN/2ymPf2XxnmVO07sj8vK0H+wVpsYV2oucDabxd1sMhqIrR16xpWjN7S6fbOufSEB0763LR6DlFRz0XpTjHSO6Z8NnEUXS+E78uV5pM0VbC5rbAolGhuREBD1/A6wslU/4IMuOPnaRb/5izoCp8kzd/bNIwnpKLDUc8OE+xopNKOViabJtJnmrCtlhh5+Wk6Qx4ExOx2i99thPDFsjN6v77UObu03jalWiP+MmccYKltgGXuObCXnl6f9fgrhT8sOKL29971ZgaiTAG/nhV3Bin2Sa0g9aLvM4ayBw/ogT8A9iViYYA+tFrvfzMdPhhmBv/X25yiEahOPkgbazSwqJMPQY0YU9gKsMkUQUdoj7AK80QpWKpYUrYzBefBeiXtHmTN5bpCv5S2AO41f6C7pifmUs= adjoly@2E2.42angouleme.fr

View File

@ -0,0 +1 @@
ls -mFt

View File

@ -0,0 +1,2 @@
#!/bin/sh
git log -5 --format=%H

View File

@ -0,0 +1,2 @@
#!/bin/sh
git ls-files -io --exclude-standard

11
finish/shell00/ex07/b Normal file
View File

@ -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..

View File

@ -0,0 +1 @@
find . -type f \( -name "*~" -or -name "#*#" \) -print -delete

View File

@ -0,0 +1 @@
41 string 42 42 file

View File

@ -0,0 +1,2 @@
#!/bin/sh
id -nG $FT_USER | tr ' ' ',' | tr -d '\n'

View File

@ -0,0 +1,2 @@
#!/bin/sh
find -type f -name "*.sh" -exec basename {} .sh \;

View File

@ -0,0 +1,2 @@
#!/bin/sh
find . -type f,d | wc -l

View File

@ -0,0 +1 @@
ifconfig | grep ether | awk '{print $2;}'

View File

@ -0,0 +1 @@
42

View File

@ -0,0 +1 @@
ls -l | sed -n {1~2p}