├── 42-cursus ├── README.md ├── circle_0 │ └── libft │ │ ├── Makefile │ │ ├── README.md │ │ ├── assets │ │ ├── es.subject.pdf │ │ └── header_libft.png │ │ ├── inc │ │ └── libft.h │ │ └── src │ │ ├── ft_atoi.c │ │ ├── ft_bzero.c │ │ ├── ft_calloc.c │ │ ├── ft_isalnum.c │ │ ├── ft_isalpha.c │ │ ├── ft_isascii.c │ │ ├── ft_isdigit.c │ │ ├── ft_isprint.c │ │ ├── ft_itoa.c │ │ ├── ft_lstadd_back_bonus.c │ │ ├── ft_lstadd_front_bonus.c │ │ ├── ft_lstclear_bonus.c │ │ ├── ft_lstdelone_bonus.c │ │ ├── ft_lstiter_bonus.c │ │ ├── ft_lstlast_bonus.c │ │ ├── ft_lstmap_bonus.c │ │ ├── ft_lstnew_bonus.c │ │ ├── ft_lstsize_bonus.c │ │ ├── ft_memchr.c │ │ ├── ft_memcmp.c │ │ ├── ft_memcpy.c │ │ ├── ft_memmove.c │ │ ├── ft_memset.c │ │ ├── ft_putchar_fd.c │ │ ├── ft_putendl_fd.c │ │ ├── ft_putnbr_fd.c │ │ ├── ft_putstr_fd.c │ │ ├── ft_split.c │ │ ├── ft_strchr.c │ │ ├── ft_strdup.c │ │ ├── ft_striteri.c │ │ ├── ft_strjoin.c │ │ ├── ft_strlcat.c │ │ ├── ft_strlcpy.c │ │ ├── ft_strlen.c │ │ ├── ft_strmapi.c │ │ ├── ft_strncmp.c │ │ ├── ft_strnstr.c │ │ ├── ft_strrchr.c │ │ ├── ft_strtrim.c │ │ ├── ft_substr.c │ │ ├── ft_tolower.c │ │ └── ft_toupper.c ├── circle_1 │ ├── Born2beroot │ │ ├── README.md │ │ └── assets │ │ │ ├── en.subject.pdf │ │ │ └── header_bor2beroot.png │ ├── ft_printf │ │ ├── README.md │ │ ├── assets │ │ │ ├── es.subject.pdf │ │ │ └── header_ft_printf.png │ │ ├── ft_printf │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ │ └── ft_printf.h │ │ │ ├── libft │ │ │ │ ├── Makefile │ │ │ │ ├── ft_atoi.c │ │ │ │ ├── ft_bzero.c │ │ │ │ ├── ft_calloc.c │ │ │ │ ├── ft_isalnum.c │ │ │ │ ├── ft_isalpha.c │ │ │ │ ├── ft_isascii.c │ │ │ │ ├── ft_isdigit.c │ │ │ │ ├── ft_isprint.c │ │ │ │ ├── ft_itoa.c │ │ │ │ ├── ft_itoa_base.c │ │ │ │ ├── ft_lstadd_back_bonus.c │ │ │ │ ├── ft_lstadd_front_bonus.c │ │ │ │ ├── ft_lstclear_bonus.c │ │ │ │ ├── ft_lstdelone_bonus.c │ │ │ │ ├── ft_lstiter_bonus.c │ │ │ │ ├── ft_lstlast_bonus.c │ │ │ │ ├── ft_lstmap_bonus.c │ │ │ │ ├── ft_lstnew_bonus.c │ │ │ │ ├── ft_lstsize_bonus.c │ │ │ │ ├── ft_ltoa.c │ │ │ │ ├── ft_memchr.c │ │ │ │ ├── ft_memcmp.c │ │ │ │ ├── ft_memcpy.c │ │ │ │ ├── ft_memmove.c │ │ │ │ ├── ft_memset.c │ │ │ │ ├── ft_putchar_fd.c │ │ │ │ ├── ft_putendl_fd.c │ │ │ │ ├── ft_putnbr_fd.c │ │ │ │ ├── ft_putstr_fd.c │ │ │ │ ├── ft_split.c │ │ │ │ ├── ft_strchr.c │ │ │ │ ├── ft_strdup.c │ │ │ │ ├── ft_striteri.c │ │ │ │ ├── ft_strjoin.c │ │ │ │ ├── ft_strlcat.c │ │ │ │ ├── ft_strlcpy.c │ │ │ │ ├── ft_strlen.c │ │ │ │ ├── ft_strmapi.c │ │ │ │ ├── ft_strncmp.c │ │ │ │ ├── ft_strnstr.c │ │ │ │ ├── ft_strrchr.c │ │ │ │ ├── ft_strtrim.c │ │ │ │ ├── ft_substr.c │ │ │ │ ├── ft_tolower.c │ │ │ │ ├── ft_toupper.c │ │ │ │ ├── ft_toupper_str.c │ │ │ │ └── libft.h │ │ │ └── src │ │ │ │ ├── ft_converter_csp.c │ │ │ │ ├── ft_converter_iduxo.c │ │ │ │ ├── ft_print_utilities.c │ │ │ │ ├── ft_printf.c │ │ │ │ └── ft_printf_checker.c │ │ └── ft_printf_bonus │ │ │ ├── Makefile │ │ │ ├── ft_flags.c │ │ │ ├── ft_flags_utils.c │ │ │ ├── ft_nbr_len.c │ │ │ ├── ft_print_char.c │ │ │ ├── ft_print_flag.c │ │ │ ├── ft_print_hex.c │ │ │ ├── ft_print_int.c │ │ │ ├── ft_print_ptr.c │ │ │ ├── ft_print_str.c │ │ │ ├── ft_print_unsigned.c │ │ │ ├── ft_printf.c │ │ │ ├── ft_printf.h │ │ │ ├── ft_printf_itoa.c │ │ │ ├── ft_printf_utoa.c │ │ │ ├── ft_printf_xtoa.c │ │ │ └── libft │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── ft_atoi.c │ │ │ ├── ft_bzero.c │ │ │ ├── ft_calloc.c │ │ │ ├── ft_isalnum.c │ │ │ ├── ft_isalpha.c │ │ │ ├── ft_isascii.c │ │ │ ├── ft_isdigit.c │ │ │ ├── ft_isprint.c │ │ │ ├── ft_itoa.c │ │ │ ├── ft_lstadd_back.c │ │ │ ├── ft_lstadd_front.c │ │ │ ├── ft_lstclear.c │ │ │ ├── ft_lstdelone.c │ │ │ ├── ft_lstiter.c │ │ │ ├── ft_lstlast.c │ │ │ ├── ft_lstmap.c │ │ │ ├── ft_lstnew.c │ │ │ ├── ft_lstsize.c │ │ │ ├── ft_memchr.c │ │ │ ├── ft_memcmp.c │ │ │ ├── ft_memcpy.c │ │ │ ├── ft_memmove.c │ │ │ ├── ft_memset.c │ │ │ ├── ft_putchar_fd.c │ │ │ ├── ft_putendl_fd.c │ │ │ ├── ft_putnbr_fd.c │ │ │ ├── ft_putstr_fd.c │ │ │ ├── ft_split.c │ │ │ ├── ft_strchr.c │ │ │ ├── ft_strdup.c │ │ │ ├── ft_striteri.c │ │ │ ├── ft_strjoin.c │ │ │ ├── ft_strlcat.c │ │ │ ├── ft_strlcpy.c │ │ │ ├── ft_strlen.c │ │ │ ├── ft_strmapi.c │ │ │ ├── ft_strncmp.c │ │ │ ├── ft_strnstr.c │ │ │ ├── ft_strrchr.c │ │ │ ├── ft_strtrim.c │ │ │ ├── ft_substr.c │ │ │ ├── ft_tolower.c │ │ │ ├── ft_toupper.c │ │ │ └── libft.h │ └── get_next_line │ │ ├── README.md │ │ ├── assets │ │ ├── es.subject.pdf │ │ └── header_get_next_line.png │ │ ├── bonus │ │ ├── get_next_line_bonus.c │ │ ├── get_next_line_bonus.h │ │ └── get_next_line_utils_bonus.c │ │ ├── inc │ │ └── get_next_line.h │ │ └── src │ │ ├── get_next_line.c │ │ └── get_next_line_utils.c ├── circle_2 │ ├── exam_rank_02 │ │ ├── README.md │ │ ├── assets │ │ │ ├── exam_rank_02_header.png │ │ │ └── grademe_01.png │ │ ├── level_0 │ │ │ ├── first_word │ │ │ │ ├── README.md │ │ │ │ └── first_word.c │ │ │ ├── fizzbuzz │ │ │ │ ├── README.md │ │ │ │ └── fizzbuzz.c │ │ │ ├── ft_putstr │ │ │ │ ├── README.md │ │ │ │ └── ft_putstr.c │ │ │ ├── ft_strcpy │ │ │ │ ├── README.md │ │ │ │ └── ft_strcpy.c │ │ │ ├── ft_strlen │ │ │ │ ├── README.md │ │ │ │ └── ft_strlen.c │ │ │ ├── ft_swap │ │ │ │ ├── README.md │ │ │ │ └── ft_swap.c │ │ │ ├── repeat_alpha │ │ │ │ ├── README.md │ │ │ │ └── repeat_alpha.c │ │ │ ├── rev_print │ │ │ │ ├── README.md │ │ │ │ └── rev_print.c │ │ │ ├── rot_13 │ │ │ │ ├── README.md │ │ │ │ └── rot_13.c │ │ │ ├── rotone │ │ │ │ ├── README.md │ │ │ │ └── rotone.c │ │ │ ├── search_and_replace │ │ │ │ ├── README.md │ │ │ │ └── search_and_replace.c │ │ │ └── ulstr │ │ │ │ ├── README.md │ │ │ │ └── ulstr.c │ │ ├── level_1 │ │ │ ├── alpha_mirror │ │ │ │ ├── README.md │ │ │ │ └── alpha_mirror.c │ │ │ ├── camel_to_snake │ │ │ │ ├── README.md │ │ │ │ └── camel_to_snake.c │ │ │ ├── do_op │ │ │ │ ├── README.md │ │ │ │ └── do_op.c │ │ │ ├── ft_atoi │ │ │ │ ├── README.md │ │ │ │ └── ft_atoi.c │ │ │ ├── ft_strcmp │ │ │ │ ├── README.md │ │ │ │ └── ft_strcmp.c │ │ │ ├── ft_strcspn │ │ │ │ ├── README.md │ │ │ │ └── ft_strcspn.c │ │ │ ├── ft_strdup │ │ │ │ ├── README.md │ │ │ │ └── ft_strdup.c │ │ │ ├── ft_strpbrk │ │ │ │ ├── README.md │ │ │ │ └── ft_strpbrk.c │ │ │ ├── ft_strrev │ │ │ │ ├── README.md │ │ │ │ └── ft_strrev.c │ │ │ ├── ft_strspn │ │ │ │ ├── README.md │ │ │ │ └── ft_strspn.c │ │ │ ├── inter │ │ │ │ ├── README.md │ │ │ │ └── inter.c │ │ │ ├── is_power_of_2 │ │ │ │ ├── README.md │ │ │ │ └── is_power_of_2.c │ │ │ ├── last_word │ │ │ │ ├── README.md │ │ │ │ └── last_word.c │ │ │ ├── max │ │ │ │ ├── README.md │ │ │ │ └── max.c │ │ │ ├── print_bits │ │ │ │ ├── README.md │ │ │ │ └── print_bits.c │ │ │ ├── reverse_bits │ │ │ │ ├── README.md │ │ │ │ └── reverse_bits.c │ │ │ ├── snake_to_camel │ │ │ │ ├── README.md │ │ │ │ └── snake_to_camel.c │ │ │ ├── swap_bits │ │ │ │ ├── README.md │ │ │ │ └── swap_bits.c │ │ │ └── wdmatch │ │ │ │ ├── README.md │ │ │ │ └── wdmatch.c │ │ ├── level_2 │ │ │ ├── add_prime_sum │ │ │ │ ├── README.md │ │ │ │ └── add_prime_sum.c │ │ │ ├── epur_str │ │ │ │ ├── README.md │ │ │ │ └── epur_str.c │ │ │ ├── expand_str │ │ │ │ ├── README.md │ │ │ │ └── expand_str.c │ │ │ ├── ft_atoi_base │ │ │ │ ├── README.md │ │ │ │ └── ft_atoi_base.c │ │ │ ├── ft_list_size │ │ │ │ ├── README.md │ │ │ │ ├── ft_list.h │ │ │ │ └── ft_list_size.c │ │ │ ├── ft_range │ │ │ │ ├── README.md │ │ │ │ └── ft_range.c │ │ │ ├── ft_rrange │ │ │ │ ├── README.md │ │ │ │ └── ft_rrange.c │ │ │ ├── hidenp │ │ │ │ ├── README.md │ │ │ │ └── hidenp.c │ │ │ ├── lcm │ │ │ │ ├── README.md │ │ │ │ └── lcm.c │ │ │ ├── paramsum │ │ │ │ ├── README.md │ │ │ │ └── paramsum.c │ │ │ ├── pgcd │ │ │ │ ├── README.md │ │ │ │ └── pgcd.c │ │ │ ├── print_hex │ │ │ │ ├── README.md │ │ │ │ └── print_hex.c │ │ │ ├── rstr_capitalizer │ │ │ │ ├── README.md │ │ │ │ └── rstr_capitalizer.c │ │ │ ├── str_capitalizer │ │ │ │ ├── README.md │ │ │ │ └── str_capitalizer.c │ │ │ └── tab_mult │ │ │ │ ├── README.md │ │ │ │ └── tab_mult.c │ │ └── level_3 │ │ │ ├── flood_fill │ │ │ ├── README.md │ │ │ ├── flood_fill.c │ │ │ └── flood_fill.t_point.h │ │ │ ├── fprime │ │ │ ├── README.md │ │ │ └── fprime.c │ │ │ ├── ft_itoa │ │ │ ├── README.md │ │ │ └── ft_itoa.c │ │ │ ├── ft_list_foreach │ │ │ ├── README.md │ │ │ ├── ft_list.h │ │ │ └── ft_list_foreach.c │ │ │ ├── ft_list_remove_if │ │ │ ├── README.md │ │ │ └── ft_list_remove_if.c │ │ │ ├── ft_split │ │ │ ├── README.md │ │ │ └── ft_split.c │ │ │ ├── rev_wstr │ │ │ ├── README.md │ │ │ └── rev_wstr.c │ │ │ ├── rostring │ │ │ ├── README.md │ │ │ └── rostring.c │ │ │ ├── sort_int_tab │ │ │ ├── README.md │ │ │ └── sort_int_tab.c │ │ │ └── sort_list │ │ │ ├── README.md │ │ │ ├── sort_list.c │ │ │ └── sort_list.list.h │ ├── fract-ol │ │ ├── Makefile │ │ ├── README.md │ │ ├── assets │ │ │ ├── es.subject.pdf │ │ │ ├── fractal_preview.png │ │ │ └── header_fractol.png │ │ ├── inc │ │ │ └── fractol.h │ │ ├── libs │ │ │ ├── libft │ │ │ │ ├── Makefile │ │ │ │ ├── inc │ │ │ │ │ ├── ft_printf.h │ │ │ │ │ ├── get_next_line.h │ │ │ │ │ └── libft.h │ │ │ │ └── src │ │ │ │ │ ├── ft_atof.c │ │ │ │ │ ├── ft_atoi.c │ │ │ │ │ ├── ft_bzero.c │ │ │ │ │ ├── ft_calloc.c │ │ │ │ │ ├── ft_isalnum.c │ │ │ │ │ ├── ft_isalpha.c │ │ │ │ │ ├── ft_isascii.c │ │ │ │ │ ├── ft_isdigit.c │ │ │ │ │ ├── ft_isprint.c │ │ │ │ │ ├── ft_itoa.c │ │ │ │ │ ├── ft_itoa_base.c │ │ │ │ │ ├── ft_lstadd_back.c │ │ │ │ │ ├── ft_lstadd_front.c │ │ │ │ │ ├── ft_lstclear.c │ │ │ │ │ ├── ft_lstdelone.c │ │ │ │ │ ├── ft_lstiter.c │ │ │ │ │ ├── ft_lstlast.c │ │ │ │ │ ├── ft_lstmap.c │ │ │ │ │ ├── ft_lstnew.c │ │ │ │ │ ├── ft_lstsize.c │ │ │ │ │ ├── ft_ltoa.c │ │ │ │ │ ├── ft_memchr.c │ │ │ │ │ ├── ft_memcmp.c │ │ │ │ │ ├── ft_memcpy.c │ │ │ │ │ ├── ft_memfree.c │ │ │ │ │ ├── ft_memfree_all.c │ │ │ │ │ ├── ft_memmove.c │ │ │ │ │ ├── ft_memset.c │ │ │ │ │ ├── ft_printf.c │ │ │ │ │ ├── ft_putchar_fd.c │ │ │ │ │ ├── ft_putendl_fd.c │ │ │ │ │ ├── ft_putnbr_fd.c │ │ │ │ │ ├── ft_putstr_fd.c │ │ │ │ │ ├── ft_split.c │ │ │ │ │ ├── ft_strchr.c │ │ │ │ │ ├── ft_strcmp.c │ │ │ │ │ ├── ft_strdup.c │ │ │ │ │ ├── ft_striteri.c │ │ │ │ │ ├── ft_strjoin.c │ │ │ │ │ ├── ft_strlcat.c │ │ │ │ │ ├── ft_strlcpy.c │ │ │ │ │ ├── ft_strlen.c │ │ │ │ │ ├── ft_strmapi.c │ │ │ │ │ ├── ft_strncmp.c │ │ │ │ │ ├── ft_strnstr.c │ │ │ │ │ ├── ft_strrchr.c │ │ │ │ │ ├── ft_strtrim.c │ │ │ │ │ ├── ft_substr.c │ │ │ │ │ ├── ft_tolower.c │ │ │ │ │ ├── ft_toupper.c │ │ │ │ │ ├── ft_toupper_str.c │ │ │ │ │ ├── get_next_line.c │ │ │ │ │ ├── gnl_utils.c │ │ │ │ │ ├── pf_checker.c │ │ │ │ │ ├── pf_converter_csp.c │ │ │ │ │ ├── pf_converter_iduxo.c │ │ │ │ │ └── pf_utils.c │ │ │ └── libmlx │ │ │ │ ├── CODE_OF_CONDUCT.md │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── Makefile_Unix.mk │ │ │ │ ├── Makefile_WindowsNT.mk │ │ │ │ ├── README.md │ │ │ │ ├── SECURITY.md │ │ │ │ ├── VERSION.md │ │ │ │ ├── docs │ │ │ │ ├── Basics.md │ │ │ │ ├── Colors.md │ │ │ │ ├── Functions.md │ │ │ │ ├── Hooks.md │ │ │ │ ├── Images.md │ │ │ │ ├── Input.md │ │ │ │ ├── Shaders.md │ │ │ │ ├── Textures.md │ │ │ │ ├── XPM42.md │ │ │ │ ├── assets │ │ │ │ │ ├── XPM_Demo.png │ │ │ │ │ └── logo.png │ │ │ │ └── index.md │ │ │ │ ├── include │ │ │ │ ├── KHR │ │ │ │ │ └── khrplatform.h │ │ │ │ ├── MLX42 │ │ │ │ │ ├── MLX42.h │ │ │ │ │ ├── MLX42_Input.h │ │ │ │ │ └── MLX42_Int.h │ │ │ │ ├── glad │ │ │ │ │ └── glad.h │ │ │ │ └── lodepng │ │ │ │ │ └── lodepng.h │ │ │ │ ├── lib │ │ │ │ ├── glad │ │ │ │ │ └── glad.c │ │ │ │ └── png │ │ │ │ │ └── lodepng.c │ │ │ │ ├── shaders │ │ │ │ ├── default.frag │ │ │ │ └── default.vert │ │ │ │ ├── src │ │ │ │ ├── font │ │ │ │ │ ├── font.h │ │ │ │ │ └── mlx_font.c │ │ │ │ ├── mlx_cursor.c │ │ │ │ ├── mlx_exit.c │ │ │ │ ├── mlx_images.c │ │ │ │ ├── mlx_init.c │ │ │ │ ├── mlx_keys.c │ │ │ │ ├── mlx_loop.c │ │ │ │ ├── mlx_monitor.c │ │ │ │ ├── mlx_mouse.c │ │ │ │ ├── mlx_put_pixel.c │ │ │ │ ├── mlx_window.c │ │ │ │ ├── textures │ │ │ │ │ ├── mlx_png.c │ │ │ │ │ ├── mlx_texture.c │ │ │ │ │ └── mlx_xpm42.c │ │ │ │ └── utils │ │ │ │ │ ├── mlx_error.c │ │ │ │ │ ├── mlx_list.c │ │ │ │ │ └── mlx_utils.c │ │ │ │ ├── test │ │ │ │ ├── Makefile │ │ │ │ ├── Tester.h │ │ │ │ └── src │ │ │ │ │ ├── img_del_test.c │ │ │ │ │ ├── init_test.c │ │ │ │ │ ├── prim_str_draw.c │ │ │ │ │ └── put_pixel_test.c │ │ │ │ └── tools │ │ │ │ ├── compile_shader.bat │ │ │ │ ├── compile_shader.sh │ │ │ │ └── xpm3_conv.py │ │ └── src │ │ │ ├── calc_color.c │ │ │ ├── color.c │ │ │ ├── fractals │ │ │ ├── burning_ship.c │ │ │ ├── julia.c │ │ │ ├── mandelbrot.c │ │ │ └── tricorn.c │ │ │ ├── keys.c │ │ │ ├── main.c │ │ │ ├── user_interface.c │ │ │ └── utils.c │ ├── pipex │ │ ├── Makefile │ │ ├── README.md │ │ ├── assets │ │ │ ├── es.subject.pdf │ │ │ └── header_pipex.png │ │ ├── bonus │ │ │ ├── main_bonus.c │ │ │ └── utils_bonus.c │ │ ├── inc │ │ │ ├── pipex.h │ │ │ └── pipex_bonus.h │ │ ├── libft │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ │ └── libft.h │ │ │ └── src │ │ │ │ ├── ft_atoi.c │ │ │ │ ├── ft_bzero.c │ │ │ │ ├── ft_calloc.c │ │ │ │ ├── ft_isalnum.c │ │ │ │ ├── ft_isalpha.c │ │ │ │ ├── ft_isascii.c │ │ │ │ ├── ft_isdigit.c │ │ │ │ ├── ft_isprint.c │ │ │ │ ├── ft_itoa.c │ │ │ │ ├── ft_itoa_base.c │ │ │ │ ├── ft_lstadd_back.c │ │ │ │ ├── ft_lstadd_front.c │ │ │ │ ├── ft_lstclear.c │ │ │ │ ├── ft_lstdelone.c │ │ │ │ ├── ft_lstiter.c │ │ │ │ ├── ft_lstlast.c │ │ │ │ ├── ft_lstmap.c │ │ │ │ ├── ft_lstnew.c │ │ │ │ ├── ft_lstsize.c │ │ │ │ ├── ft_ltoa.c │ │ │ │ ├── ft_memchr.c │ │ │ │ ├── ft_memcmp.c │ │ │ │ ├── ft_memcpy.c │ │ │ │ ├── ft_memfree.c │ │ │ │ ├── ft_memfree_all.c │ │ │ │ ├── ft_memmove.c │ │ │ │ ├── ft_memset.c │ │ │ │ ├── ft_printf.c │ │ │ │ ├── ft_putchar_fd.c │ │ │ │ ├── ft_putendl_fd.c │ │ │ │ ├── ft_putnbr_fd.c │ │ │ │ ├── ft_putstr_fd.c │ │ │ │ ├── ft_split.c │ │ │ │ ├── ft_strchr.c │ │ │ │ ├── ft_strcmp.c │ │ │ │ ├── ft_strdup.c │ │ │ │ ├── ft_striteri.c │ │ │ │ ├── ft_strjoin.c │ │ │ │ ├── ft_strlcat.c │ │ │ │ ├── ft_strlcpy.c │ │ │ │ ├── ft_strlen.c │ │ │ │ ├── ft_strmapi.c │ │ │ │ ├── ft_strncmp.c │ │ │ │ ├── ft_strnstr.c │ │ │ │ ├── ft_strrchr.c │ │ │ │ ├── ft_strtrim.c │ │ │ │ ├── ft_substr.c │ │ │ │ ├── ft_tolower.c │ │ │ │ ├── ft_toupper.c │ │ │ │ ├── ft_toupper_str.c │ │ │ │ ├── get_next_line.c │ │ │ │ ├── gnl_utils.c │ │ │ │ ├── pf_checker.c │ │ │ │ ├── pf_converter_csp.c │ │ │ │ ├── pf_converter_iduxo.c │ │ │ │ └── pf_utils.c │ │ └── src │ │ │ ├── main.c │ │ │ └── utils.c │ └── push_swap │ │ ├── Makefile │ │ ├── README.md │ │ ├── assets │ │ ├── es.subject.pdf │ │ └── header_push_swap.png │ │ ├── inc │ │ └── push_swap.h │ │ ├── libft │ │ ├── Makefile │ │ ├── inc │ │ │ ├── ft_printf.h │ │ │ ├── get_next_line.h │ │ │ └── libft.h │ │ └── src │ │ │ ├── ft_atof.c │ │ │ ├── ft_atoi.c │ │ │ ├── ft_bzero.c │ │ │ ├── ft_calloc.c │ │ │ ├── ft_iabs.c │ │ │ ├── ft_is_digit_sign.c │ │ │ ├── ft_isalnum.c │ │ │ ├── ft_isalpha.c │ │ │ ├── ft_isascii.c │ │ │ ├── ft_isdigit.c │ │ │ ├── ft_isprint.c │ │ │ ├── ft_issign.c │ │ │ ├── ft_itoa.c │ │ │ ├── ft_itoa_base.c │ │ │ ├── ft_lstadd_back.c │ │ │ ├── ft_lstadd_front.c │ │ │ ├── ft_lstclear.c │ │ │ ├── ft_lstdelone.c │ │ │ ├── ft_lstiter.c │ │ │ ├── ft_lstlast.c │ │ │ ├── ft_lstmap.c │ │ │ ├── ft_lstnew.c │ │ │ ├── ft_lstsize.c │ │ │ ├── ft_ltoa.c │ │ │ ├── ft_memchr.c │ │ │ ├── ft_memcmp.c │ │ │ ├── ft_memcpy.c │ │ │ ├── ft_memfree.c │ │ │ ├── ft_memfree_all.c │ │ │ ├── ft_memmove.c │ │ │ ├── ft_memset.c │ │ │ ├── ft_printf.c │ │ │ ├── ft_putchar_fd.c │ │ │ ├── ft_putendl_fd.c │ │ │ ├── ft_putnbr_fd.c │ │ │ ├── ft_putstr_fd.c │ │ │ ├── ft_split.c │ │ │ ├── ft_strchr.c │ │ │ ├── ft_strcmp.c │ │ │ ├── ft_strdup.c │ │ │ ├── ft_striteri.c │ │ │ ├── ft_strjoin.c │ │ │ ├── ft_strlcat.c │ │ │ ├── ft_strlcpy.c │ │ │ ├── ft_strlen.c │ │ │ ├── ft_strmapi.c │ │ │ ├── ft_strncmp.c │ │ │ ├── ft_strnstr.c │ │ │ ├── ft_strrchr.c │ │ │ ├── ft_strtrim.c │ │ │ ├── ft_substr.c │ │ │ ├── ft_tolower.c │ │ │ ├── ft_toupper.c │ │ │ ├── ft_toupper_str.c │ │ │ ├── get_next_line.c │ │ │ ├── gnl_utils.c │ │ │ ├── pf_checker.c │ │ │ ├── pf_converter_csp.c │ │ │ ├── pf_converter_iduxo.c │ │ │ └── pf_utils.c │ │ └── src │ │ ├── checker │ │ └── checker.c │ │ └── push_swap │ │ ├── algorithm.c │ │ ├── algorithm_utils.c │ │ ├── check_args.c │ │ ├── main.c │ │ ├── move.c │ │ ├── operations │ │ ├── push.c │ │ ├── reverse_rotate.c │ │ ├── rotate.c │ │ └── swap.c │ │ ├── position.c │ │ ├── stack.c │ │ └── utils.c ├── circle_3 │ ├── exam_rank_03 │ │ ├── README.md │ │ ├── assets │ │ │ ├── exam_rank_03_header.png │ │ │ └── grademe_01.png │ │ ├── ft_printf.c │ │ └── get_next_line.c │ └── philosophers │ │ ├── README.md │ │ ├── assets │ │ ├── es.subject.pdf │ │ ├── header_philo.png │ │ ├── img1.png │ │ └── img2.png │ │ ├── philo │ │ ├── Makefile │ │ ├── include │ │ │ └── philo.h │ │ └── src │ │ │ ├── check_args.c │ │ │ ├── init.c │ │ │ ├── main.c │ │ │ ├── routine.c │ │ │ ├── sim_utils.c │ │ │ ├── simulation.c │ │ │ └── utils.c │ │ └── philo_bonus │ │ ├── Makefile │ │ ├── include │ │ └── philo_bonus.h │ │ └── src │ │ ├── check_args.c │ │ ├── init.c │ │ ├── main.c │ │ ├── routine.c │ │ ├── routine_utils.c │ │ └── utils.c ├── circle_4 │ ├── CPP_Module_0-4 │ │ ├── Module_00 │ │ │ ├── en.subject.pdf │ │ │ ├── ex00 │ │ │ │ ├── Makefile │ │ │ │ └── megaphone.cpp │ │ │ ├── ex01 │ │ │ │ ├── Makefile │ │ │ │ ├── include │ │ │ │ │ ├── Contact.hpp │ │ │ │ │ └── PhoneBook.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── src │ │ │ │ │ ├── Contact.cpp │ │ │ │ │ └── PhoneBook.cpp │ │ │ └── ex02 │ │ │ │ ├── Account.cpp │ │ │ │ ├── Account.hpp │ │ │ │ ├── Makefile │ │ │ │ └── tests.cpp │ │ ├── Module_01 │ │ │ ├── en.subject.pdf │ │ │ ├── ex00 │ │ │ │ ├── Makefile │ │ │ │ ├── Zombie.cpp │ │ │ │ ├── Zombie.hpp │ │ │ │ ├── main.cpp │ │ │ │ ├── newZombie.cpp │ │ │ │ └── randomChump.cpp │ │ │ ├── ex01 │ │ │ │ ├── Makefile │ │ │ │ ├── Zombie.cpp │ │ │ │ ├── Zombie.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── zombieHorde.cpp │ │ │ ├── ex02 │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ ├── ex03 │ │ │ │ ├── Makefile │ │ │ │ ├── inc │ │ │ │ │ ├── HumanA.hpp │ │ │ │ │ ├── HumanB.hpp │ │ │ │ │ └── Weapon.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── src │ │ │ │ │ ├── HumanA.cpp │ │ │ │ │ ├── HumanB.cpp │ │ │ │ │ └── Weapon.cpp │ │ │ ├── ex04 │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ ├── ex05 │ │ │ │ ├── Harl.cpp │ │ │ │ ├── Harl.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ └── ex06 │ │ │ │ ├── Harl.cpp │ │ │ │ ├── Harl.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ ├── Module_02 │ │ │ ├── en.subject.pdf │ │ │ ├── ex00 │ │ │ │ ├── Fixed.cpp │ │ │ │ ├── Fixed.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ ├── ex01 │ │ │ │ ├── Fixed.cpp │ │ │ │ ├── Fixed.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ └── ex02 │ │ │ │ ├── Fixed.cpp │ │ │ │ ├── Fixed.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ ├── Module_03 │ │ │ ├── en.subject.pdf │ │ │ ├── ex00 │ │ │ │ ├── ClapTrap.cpp │ │ │ │ ├── ClapTrap.hpp │ │ │ │ ├── Makefile │ │ │ │ └── main.cpp │ │ │ ├── ex01 │ │ │ │ ├── Makefile │ │ │ │ ├── inc │ │ │ │ │ ├── ClapTrap.hpp │ │ │ │ │ └── ScavTrap.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── src │ │ │ │ │ ├── ClapTrap.cpp │ │ │ │ │ └── ScavTrap.cpp │ │ │ ├── ex02 │ │ │ │ ├── Makefile │ │ │ │ ├── inc │ │ │ │ │ ├── ClapTrap.hpp │ │ │ │ │ ├── FragTrap.hpp │ │ │ │ │ └── ScavTrap.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── src │ │ │ │ │ ├── ClapTrap.cpp │ │ │ │ │ ├── FragTrap.cpp │ │ │ │ │ └── ScavTrap.cpp │ │ │ └── ex03 │ │ │ │ ├── Makefile │ │ │ │ ├── inc │ │ │ │ ├── ClapTrap.hpp │ │ │ │ ├── DiamondTrap.hpp │ │ │ │ ├── FragTrap.hpp │ │ │ │ └── ScavTrap.hpp │ │ │ │ ├── main.cpp │ │ │ │ └── src │ │ │ │ ├── ClapTrap.cpp │ │ │ │ ├── DiamoundTrap.cpp │ │ │ │ ├── FragTrap.cpp │ │ │ │ └── ScavTrap.cpp │ │ └── Module_04 │ │ │ ├── en.subject.pdf │ │ │ ├── ex00 │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ │ ├── Animal.hpp │ │ │ │ ├── Cat.hpp │ │ │ │ ├── Dog.hpp │ │ │ │ ├── WrongAnimal.hpp │ │ │ │ └── WrongCat.hpp │ │ │ ├── main.cpp │ │ │ └── src │ │ │ │ ├── Animal.cpp │ │ │ │ ├── Cat.cpp │ │ │ │ ├── Dog.cpp │ │ │ │ ├── WrongAnimal.cpp │ │ │ │ └── WrongCat.cpp │ │ │ ├── ex01 │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ │ ├── Animal.hpp │ │ │ │ ├── Brain.hpp │ │ │ │ ├── Cat.hpp │ │ │ │ ├── Dog.hpp │ │ │ │ ├── WrongAnimal.hpp │ │ │ │ └── WrongCat.hpp │ │ │ ├── main.cpp │ │ │ └── src │ │ │ │ ├── Animal.cpp │ │ │ │ ├── Brain.cpp │ │ │ │ ├── Cat.cpp │ │ │ │ ├── Dog.cpp │ │ │ │ ├── WrongAnimal.cpp │ │ │ │ └── WrongCat.cpp │ │ │ ├── ex02 │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ │ ├── AAnimal.hpp │ │ │ │ ├── Brain.hpp │ │ │ │ ├── Cat.hpp │ │ │ │ ├── Dog.hpp │ │ │ │ ├── WrongAnimal.hpp │ │ │ │ └── WrongCat.hpp │ │ │ ├── main.cpp │ │ │ └── src │ │ │ │ ├── AAnimal.cpp │ │ │ │ ├── Brain.cpp │ │ │ │ ├── Cat.cpp │ │ │ │ ├── Dog.cpp │ │ │ │ ├── WrongAnimal.cpp │ │ │ │ └── WrongCat.cpp │ │ │ └── ex03 │ │ │ ├── Makefile │ │ │ ├── inc │ │ │ ├── AMateria.hpp │ │ │ ├── Character.hpp │ │ │ ├── Cure.hpp │ │ │ ├── ICharacter.hpp │ │ │ ├── IMateriaSource.hpp │ │ │ ├── Ice.hpp │ │ │ └── MateriaSource.hpp │ │ │ ├── main.cpp │ │ │ └── src │ │ │ ├── AMateria.cpp │ │ │ ├── Character.cpp │ │ │ ├── Cure.cpp │ │ │ ├── Ice.cpp │ │ │ └── MateriaSource.cpp │ ├── NetPractice │ │ ├── README.md │ │ └── assets │ │ │ ├── NetPractice.png │ │ │ ├── en.subject.pdf │ │ │ ├── ip1.png │ │ │ ├── ip_version.png │ │ │ ├── level10_paint.png │ │ │ ├── level1_paint.png │ │ │ ├── level2_paint.png │ │ │ ├── level3_paint.png │ │ │ ├── level4_paint.png │ │ │ ├── level5_paint.png │ │ │ ├── level6_paint.png │ │ │ ├── level7_paint.png │ │ │ ├── level8_paint.png │ │ │ ├── level9_paint.png │ │ │ ├── mask1.png │ │ │ ├── route1.png │ │ │ ├── routing_table1.png │ │ │ ├── switch1.png │ │ │ └── tcp-ip-stack.png │ └── exam_rank_04 │ │ ├── README.md │ │ ├── assets │ │ ├── exam_rank_04_header.png │ │ └── grademe_01.png │ │ ├── microshell.c │ │ └── microshell.h └── circle_5 │ └── CPP_Module_5-9 │ ├── Module_05 │ ├── en.subject.pdf │ ├── ex00 │ │ ├── Bureaucrat.cpp │ │ ├── Bureaucrat.hpp │ │ ├── Makefile │ │ └── main.cpp │ ├── ex01 │ │ ├── Makefile │ │ ├── inc │ │ │ ├── Bureaucrat.hpp │ │ │ └── Form.hpp │ │ ├── main.cpp │ │ └── src │ │ │ ├── Bureaucrat.cpp │ │ │ └── Form.cpp │ ├── ex02 │ │ ├── Makefile │ │ ├── inc │ │ │ ├── AForm.hpp │ │ │ ├── Bureaucrat.hpp │ │ │ ├── PresidentialPardonForm.hpp │ │ │ ├── RobotomyRequestForm.hpp │ │ │ └── ShrubberyCreationForm.hpp │ │ ├── main.cpp │ │ └── src │ │ │ ├── AForm.cpp │ │ │ ├── Bureaucrat.cpp │ │ │ ├── PresidentialPardonForm.cpp │ │ │ ├── RobotomyRequestForm.cpp │ │ │ └── ShrubberyCreationForm.cpp │ └── ex03 │ │ ├── Makefile │ │ ├── inc │ │ ├── AForm.hpp │ │ ├── Bureaucrat.hpp │ │ ├── Intern.hpp │ │ ├── PresidentialPardonForm.hpp │ │ ├── RobotomyRequestForm.hpp │ │ └── ShrubberyCreationForm.hpp │ │ ├── main.cpp │ │ └── src │ │ ├── AForm.cpp │ │ ├── Bureaucrat.cpp │ │ ├── Intern.cpp │ │ ├── PresidentialPardonForm.cpp │ │ ├── RobotomyRequestForm.cpp │ │ └── ShrubberyCreationForm.cpp │ ├── Module_06 │ ├── en.subject.pdf │ ├── ex00 │ │ ├── Makefile │ │ ├── ScalarConverter.cpp │ │ ├── ScalarConverter.hpp │ │ └── main.cpp │ ├── ex01 │ │ ├── Data.hpp │ │ ├── Makefile │ │ ├── Serialization.cpp │ │ ├── Serialization.hpp │ │ └── main.cpp │ └── ex02 │ │ ├── Makefile │ │ ├── inc │ │ ├── Base.hpp │ │ ├── Class_A.hpp │ │ ├── Class_B.hpp │ │ └── Class_C.hpp │ │ ├── main.cpp │ │ └── src │ │ └── Base.cpp │ ├── Module_07 │ ├── en.subject.pdf │ ├── ex00 │ │ ├── Makefile │ │ ├── main.cpp │ │ └── whatever.hpp │ ├── ex01 │ │ ├── Makefile │ │ ├── iter.hpp │ │ └── main.cpp │ └── ex02 │ │ ├── Array.hpp │ │ ├── Makefile │ │ └── main.cpp │ ├── Module_08 │ ├── en.subject.pdf │ ├── ex00 │ │ ├── Makefile │ │ ├── easyfind.hpp │ │ └── main.cpp │ ├── ex01 │ │ ├── Makefile │ │ ├── Span.cpp │ │ ├── Span.hpp │ │ └── main.cpp │ └── ex02 │ │ ├── Makefile │ │ ├── MutantStack.hpp │ │ └── main.cpp │ └── Module_09 │ ├── en.subject.pdf │ ├── ex00 │ ├── BitcoinExchange.cpp │ ├── BitcoinExchange.hpp │ ├── Makefile │ ├── main.cpp │ └── test │ │ ├── data.csv │ │ ├── emptyData.txt │ │ ├── emptyFile.txt │ │ └── input.txt │ ├── ex01 │ ├── Makefile │ ├── RPN.cpp │ ├── RPN.hpp │ └── main.cpp │ └── ex02 │ ├── Makefile │ ├── PmergeMe.cpp │ ├── PmergeMe.hpp │ └── main.cpp ├── 42-discovery_web ├── README.md ├── cell0 │ ├── ex01 │ │ └── z │ ├── ex02 │ │ └── midLS │ ├── ex03 │ │ └── count_files.sh │ ├── ex04 │ │ └── argv.sh │ └── ex05 │ │ └── build.sh ├── cell1 │ ├── ex00 │ │ └── helloworld.html │ ├── ex01 │ │ └── piscineweb.html │ ├── ex02 │ │ └── piscineweb.html │ ├── ex03 │ │ └── piscineweb.html │ ├── ex04 │ │ └── basics.html │ ├── ex05 │ │ └── tab.html │ └── ex06 │ │ └── responsive.html ├── cell2 │ ├── ex00 │ │ ├── responsive.css │ │ └── responsive.html │ ├── ex01 │ │ ├── menu.css │ │ └── menu.html │ ├── ex02 │ │ ├── parallax.css │ │ └── parallax.html │ └── ex03 │ │ ├── card.css │ │ └── card.html └── cell3 │ ├── ex00 │ ├── background.css │ └── background.html │ ├── ex01 │ └── balloon.html │ ├── ex02 │ └── calc.html │ ├── ex03 │ ├── index.html │ └── todo.js │ └── ex04 │ ├── ex00bis │ ├── background.css │ ├── background.html │ ├── background.js │ └── jQuery.js │ ├── ex01bis │ ├── balloon.css │ ├── balloon.html │ ├── balloon.js │ └── jQuery.js │ ├── ex02bis │ ├── calc.css │ ├── calc.html │ ├── calc.js │ └── jQuery.js │ └── ex03bis │ ├── index.html │ ├── jQuery.js │ ├── style.css │ └── todo.js ├── 42-piscine ├── C00 │ ├── ex00 │ │ └── ft_putchar.c │ ├── ex01 │ │ └── ft_print_alphabet.c │ ├── ex02 │ │ └── ft_print_reverse_alphabet.c │ ├── ex03 │ │ └── ft_print_numbers.c │ ├── ex04 │ │ └── ft_is_negative.c │ ├── ex05 │ │ └── ft_print_comb.c │ ├── ex06 │ │ └── ft_print_comb2.c │ ├── ex07 │ │ └── ft_putnbr.c │ └── ex08 │ │ └── ft_print_combn.c ├── C01 │ ├── ex00 │ │ └── ft_ft.c │ ├── ex01 │ │ └── ft_ultimate_ft.c │ ├── ex02 │ │ └── ft_swap.c │ ├── ex03 │ │ └── ft_div_mod.c │ ├── ex04 │ │ └── ft_ultimate_div_mod.c │ ├── ex05 │ │ └── ft_putstr.c │ ├── ex06 │ │ └── ft_strlen.c │ ├── ex07 │ │ └── ft_rev_int_tab.c │ └── ex08 │ │ └── ft_sort_int_tab.c ├── C02 │ ├── ex00 │ │ └── ft_strcpy.c │ ├── ex01 │ │ └── ft_strncpy.c │ ├── ex02 │ │ └── ft_str_is_alpha.c │ ├── ex03 │ │ └── ft_str_is_numeric.c │ ├── ex04 │ │ └── ft_str_is_lowercase.c │ ├── ex05 │ │ └── ft_str_is_uppercase.c │ ├── ex06 │ │ └── ft_str_is_printable.c │ ├── ex07 │ │ └── ft_strupcase.c │ ├── ex08 │ │ └── ft_strlowcase.c │ ├── ex09 │ │ └── ft_strcapitalize.c │ ├── ex10 │ │ └── ft_strlcpy.c │ └── ex11 │ │ └── ft_putstr_non_printable.c ├── C03 │ ├── ex00 │ │ └── ft_strcmp.c │ ├── ex01 │ │ └── ft_strncmp.c │ ├── ex02 │ │ └── ft_strcat.c │ ├── ex03 │ │ └── ft_strncat.c │ └── ex04 │ │ └── ft_strstr.c ├── C04 │ ├── ex00 │ │ └── ft_strlen.c │ ├── ex01 │ │ └── ft_putstr.c │ ├── ex02 │ │ └── ft_putnbr.c │ └── ex03 │ │ └── ft_atoi.c ├── C06 │ ├── ex00 │ │ └── ft_print_program_name.c │ ├── ex01 │ │ └── ft_print_params.c │ └── ex02 │ │ └── ft_rev_params.c ├── README.md ├── Rush00 │ └── ex00 │ │ ├── ft_putchar.c │ │ ├── main.c │ │ └── rush00.c ├── Shell00 │ ├── README.md │ ├── ex00 │ │ └── z │ ├── ex01 │ │ └── testShell00.tar │ ├── ex02 │ │ └── exo2.tar │ ├── ex03 │ │ └── id_rsa_pub │ ├── ex04 │ │ └── midLS │ ├── ex05 │ │ └── git_commit.sh │ ├── ex06 │ │ └── git_ignore.sh │ ├── ex07 │ │ └── b │ ├── ex08 │ │ └── clean │ └── ex09 │ │ └── ft_magic └── Shell01 │ ├── ex01 │ └── print_groups.sh │ ├── ex02 │ └── find_sh.sh │ ├── ex03 │ └── count_files.sh │ ├── ex04 │ └── MAC.sh │ ├── ex05 │ └── "\?$*'MaRViN'*$?\" │ ├── ex06 │ └── skip.sh │ ├── ex07 │ └── r_dwssap.sh │ └── ex08 │ └── add_chelou.sh ├── LICENSE ├── README.md └── public ├── 42-malaga-logo.jpg ├── common_core.png ├── discover_web.png ├── es_norm.pdf └── piscine.png /42-cursus/circle_0/libft/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_0/libft/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/assets/header_libft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_0/libft/assets/header_libft.png -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* transforma una string en un numero entero */ 2 | #include "libft.h" 3 | 4 | int ft_atoi(const char *str) 5 | { 6 | long atoi; 7 | int sign; 8 | 9 | atoi = 0; 10 | sign = 1; 11 | while ((*str >= 9 && *str <= 13) || *str == 32) 12 | str++; 13 | if (*str == 45 || *str == 43) 14 | { 15 | if (*str == 45) 16 | sign = -1; 17 | str++; 18 | } 19 | while (ft_isdigit(*str)) 20 | { 21 | atoi *= 10; 22 | atoi += *str - 48; 23 | str++; 24 | } 25 | return (atoi * sign); 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_bzero.c: -------------------------------------------------------------------------------- 1 | /* convierte en nulo los primeros ("size") de caracteres de la cadena "str" */ 2 | #include "libft.h" 3 | 4 | void ft_bzero(void *str, size_t size) 5 | { 6 | size_t i; 7 | char *s; 8 | 9 | i = 0; 10 | s = (char *)str; 11 | while (i < size) 12 | s[i++] = 0; 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_calloc.c: -------------------------------------------------------------------------------- 1 | /* asigna memoria dinamica a una string empezada por valores nulos */ 2 | #include "libft.h" 3 | 4 | void *ft_calloc(size_t num, size_t size) 5 | { 6 | void *p; 7 | 8 | p = malloc(num * size); 9 | if (!p) 10 | return (NULL); 11 | ft_bzero(p, (num * size)); 12 | return (p); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_isalnum.c: -------------------------------------------------------------------------------- 1 | /* verifica si el caracter "c" es alfabetico o numerico */ 2 | #include "libft.h" 3 | 4 | int ft_isalnum(int c) 5 | { 6 | return (ft_isalpha(c) || ft_isdigit(c)); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_isalpha.c: -------------------------------------------------------------------------------- 1 | /* verifica si el caracter "c" es alfabetico */ 2 | #include "libft.h" 3 | 4 | int ft_isalpha(int c) 5 | { 6 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_isascii.c: -------------------------------------------------------------------------------- 1 | /* verifica si el caracter "c" esta en la tabla ascii */ 2 | #include "libft.h" 3 | 4 | int ft_isascii(int c) 5 | { 6 | return (c >= 0 && c <= 127); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_isdigit.c: -------------------------------------------------------------------------------- 1 | /* verifica que el caracter "c" es numerico */ 2 | #include "libft.h" 3 | 4 | int ft_isdigit(int c) 5 | { 6 | return (c >= 48 && c <= 57); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_isprint.c: -------------------------------------------------------------------------------- 1 | /* verifica si el caracter "c" es imprimible */ 2 | #include "libft.h" 3 | 4 | int ft_isprint(int c) 5 | { 6 | return (c >= 32 && c <= 126); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstadd_back_bonus.c: -------------------------------------------------------------------------------- 1 | /* añade el nodo "new" al final de la lista */ 2 | #include "libft.h" 3 | 4 | void ft_lstadd_back(t_list **lst, t_list *new) 5 | { 6 | if (*lst) 7 | (ft_lstlast(*lst))->next = new; 8 | else 9 | *lst = new; 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstadd_front_bonus.c: -------------------------------------------------------------------------------- 1 | /* añade el nodo "new" al principio de la lista */ 2 | #include "libft.h" 3 | 4 | void ft_lstadd_front(t_list **lst, t_list *new) 5 | { 6 | new->next = *lst; 7 | *lst = new; 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstclear_bonus.c: -------------------------------------------------------------------------------- 1 | /* elimina todos los nodos de una lista y libera la memoria asociada */ 2 | #include "libft.h" 3 | 4 | void ft_lstclear(t_list **lst, void (*del)(void *)) 5 | { 6 | t_list *aux; 7 | 8 | while (*lst) 9 | { 10 | aux = *lst; 11 | del((*lst)->content); 12 | *lst = (*lst)->next; 13 | free(aux); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstdelone_bonus.c: -------------------------------------------------------------------------------- 1 | /*elimina un unico nodo de una lista y libera la memoria asociada a dicho nodo*/ 2 | #include "libft.h" 3 | 4 | void ft_lstdelone(t_list *lst, void (*del)(void *)) 5 | { 6 | (*del)(lst->content); 7 | free(lst); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstiter_bonus.c: -------------------------------------------------------------------------------- 1 | /* aplica la funcion "f" a cada elemento(content) de la lista enlazada(lst) */ 2 | #include "libft.h" 3 | 4 | void ft_lstiter(t_list *lst, void (*f)(void *)) 5 | { 6 | while (lst) 7 | { 8 | f(lst->content); 9 | lst = lst->next; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstlast_bonus.c: -------------------------------------------------------------------------------- 1 | /* devuelve el ultimo nodo de la lista */ 2 | #include "libft.h" 3 | 4 | t_list *ft_lstlast(t_list *lst) 5 | { 6 | if (!lst) 7 | return (NULL); 8 | while (lst->next) 9 | lst = lst->next; 10 | return (lst); 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstmap_bonus.c: -------------------------------------------------------------------------------- 1 | /* crea una nueva lista aplicando la funcion (f) a cada elemento de la 2 | lista original */ 3 | #include "libft.h" 4 | 5 | t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) 6 | { 7 | t_list *newlst; 8 | t_list *newel; 9 | 10 | if (!f || !del) 11 | return (NULL); 12 | newlst = NULL; 13 | while (lst) 14 | { 15 | newel = ft_lstnew(f(lst->content)); 16 | if (!newel) 17 | { 18 | ft_lstclear(&lst, del); 19 | return (NULL); 20 | } 21 | ft_lstadd_back(&newlst, newel); 22 | lst = lst->next; 23 | } 24 | return (newlst); 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstnew_bonus.c: -------------------------------------------------------------------------------- 1 | /* crea un nuevo nodo */ 2 | #include "libft.h" 3 | 4 | t_list *ft_lstnew(void *content) 5 | { 6 | t_list *new; 7 | 8 | new = malloc(sizeof(t_list)); 9 | if (!new) 10 | return (NULL); 11 | new->content = content; 12 | new->next = NULL; 13 | return (new); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_lstsize_bonus.c: -------------------------------------------------------------------------------- 1 | /* cuenta el numero de nodos que hay en la lista */ 2 | #include "libft.h" 3 | 4 | int ft_lstsize(t_list *lst) 5 | { 6 | int size; 7 | 8 | size = 0; 9 | while (lst) 10 | { 11 | lst = lst->next; 12 | size++; 13 | } 14 | return (size); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_memchr.c: -------------------------------------------------------------------------------- 1 | /* busca la primera aparicion del byte "c" en "str" 2 | hasta el tamano maximo(size)*/ 3 | #include "libft.h" 4 | 5 | void *ft_memchr(const void *str, int c, size_t size) 6 | { 7 | size_t i; 8 | unsigned char *pstr; 9 | 10 | i = 0; 11 | pstr = (unsigned char *)str; 12 | while (size--) 13 | { 14 | if (pstr[i] == (unsigned char)c) 15 | return (&pstr[i]); 16 | i++; 17 | } 18 | return (NULL); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_memcmp.c: -------------------------------------------------------------------------------- 1 | /* compara los primeros(size) valores de "s1" y "s2" */ 2 | #include "libft.h" 3 | 4 | int ft_memcmp(const void *s1, const void *s2, size_t size) 5 | { 6 | unsigned char *str1; 7 | unsigned char *str2; 8 | size_t i; 9 | 10 | str1 = (unsigned char *)s1; 11 | str2 = (unsigned char *)s2; 12 | i = 0; 13 | while (size--) 14 | { 15 | if (str1[i] != str2[i]) 16 | return (str1[i] - str2[i]); 17 | i++; 18 | } 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_memcpy.c: -------------------------------------------------------------------------------- 1 | /* copia los primeros(size) de valores de "src" a "dest" */ 2 | #include "libft.h" 3 | 4 | void *ft_memcpy(void *dest, const void *src, size_t size) 5 | { 6 | char *d; 7 | char *s; 8 | 9 | d = (char *)dest; 10 | s = (char *)src; 11 | if (!dest && !src) 12 | return (NULL); 13 | while (size--) 14 | *d++ = *s++; 15 | return (dest); 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_memmove.c: -------------------------------------------------------------------------------- 1 | /* copia los primeros(size) valores de "src" a "dest", hasta si se superponen */ 2 | #include "libft.h" 3 | 4 | void *ft_memmove(void *dest, const void *src, size_t size) 5 | { 6 | char *d; 7 | char *s; 8 | 9 | d = (char *)dest; 10 | s = (char *)src; 11 | if (!dest && !src) 12 | return (NULL); 13 | if (d < s) 14 | ft_memcpy(d, s, size); 15 | else 16 | { 17 | while (size--) 18 | d[size] = s[size]; 19 | } 20 | return (d); 21 | } 22 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_memset.c: -------------------------------------------------------------------------------- 1 | /* cambia el valor de los primeros "size" del string "str" por el caracter "c"*/ 2 | #include "libft.h" 3 | 4 | void *ft_memset(void *str, int c, size_t size) 5 | { 6 | size_t i; 7 | char *pstr; 8 | 9 | i = 0; 10 | pstr = (char *)str; 11 | while (i < size) 12 | pstr[i++] = c; 13 | return (str); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_putchar_fd.c: -------------------------------------------------------------------------------- 1 | /* imprime un caracter "c"... (fd es la salida) */ 2 | #include "libft.h" 3 | 4 | void ft_putchar_fd(char c, int fd) 5 | { 6 | write(fd, &c, 1); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_putendl_fd.c: -------------------------------------------------------------------------------- 1 | /* imprime una string con un salto de linea al final */ 2 | #include "libft.h" 3 | 4 | void ft_putendl_fd(char *s, int fd) 5 | { 6 | if (!s) 7 | return ; 8 | ft_putstr_fd(s, fd); 9 | ft_putchar_fd('\n', fd); 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | /* imprime un numero entero */ 2 | #include "libft.h" 3 | 4 | void ft_putnbr_fd(int n, int fd) 5 | { 6 | long nb; 7 | 8 | nb = n; 9 | if (nb < 0) 10 | { 11 | ft_putchar_fd('-', fd); 12 | nb *= -1; 13 | } 14 | if (nb >= 10) 15 | { 16 | ft_putnbr_fd(nb / 10, fd); 17 | ft_putnbr_fd(nb % 10, fd); 18 | } 19 | else 20 | ft_putchar_fd(nb + '0', fd); 21 | } 22 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_putstr_fd.c: -------------------------------------------------------------------------------- 1 | /* imprime una string */ 2 | #include "libft.h" 3 | 4 | void ft_putstr_fd(char *s, int fd) 5 | { 6 | if (!s) 7 | return ; 8 | write(fd, s, ft_strlen(s)); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strchr.c: -------------------------------------------------------------------------------- 1 | /* busca la primera aparicion del caracter "c" en la cadena "str" */ 2 | #include "libft.h" 3 | 4 | char *ft_strchr(const char *str, int c) 5 | { 6 | while (*str != (char)c) 7 | { 8 | if (!(*str)) 9 | return (NULL); 10 | str++; 11 | } 12 | return ((char *)str); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strdup.c: -------------------------------------------------------------------------------- 1 | /* asigna memoria dinamica a una string que contine "str" */ 2 | #include "libft.h" 3 | 4 | char *ft_strdup(const char *str) 5 | { 6 | int len; 7 | char *copy; 8 | 9 | len = ft_strlen(str); 10 | copy = (char *)malloc(sizeof(char) * (len + 1)); 11 | if (!copy) 12 | return (NULL); 13 | while (len >= 0) 14 | { 15 | copy[len] = str[len]; 16 | len--; 17 | } 18 | return (copy); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_striteri.c: -------------------------------------------------------------------------------- 1 | /* aplica la funcion f en cada caracter de la cadena "s" */ 2 | #include "libft.h" 3 | 4 | void ft_striteri(char *s, void (*f)(unsigned int, char *)) 5 | { 6 | size_t i; 7 | 8 | i = ft_strlen(s); 9 | while (i--) 10 | f(i, &s[i]); 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strjoin.c: -------------------------------------------------------------------------------- 1 | /* asigna MD a una string creada a partir de la concatenacion de s1 con s2 */ 2 | #include "libft.h" 3 | 4 | char *ft_strjoin(char const *s1, char const *s2) 5 | { 6 | char *str; 7 | size_t str_len; 8 | size_t i; 9 | 10 | str_len = (ft_strlen(s1) + ft_strlen(s2) + 1); 11 | str = (char *)malloc(sizeof(char) * str_len); 12 | if (!s1 || !s2 || !str) 13 | return (NULL); 14 | i = 0; 15 | while (*s1) 16 | str[i++] = *s1++; 17 | while (*s2) 18 | str[i++] = *s2++; 19 | str[i] = 0; 20 | return (str); 21 | } 22 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strlcat.c: -------------------------------------------------------------------------------- 1 | /* concatena la cadena "src" en la cadena "dest" hasta que ESTE llegue 2 | a su maximo(size) terminando en nulo */ 3 | #include "libft.h" 4 | 5 | size_t ft_strlcat(char *dest, const char *src, size_t size) 6 | { 7 | size_t len_d; 8 | size_t len_s; 9 | size_t i; 10 | 11 | len_d = ft_strlen(dest); 12 | len_s = ft_strlen(src); 13 | if (len_d >= size) 14 | return (len_s + size); 15 | else if (len_d + 1 < size) 16 | { 17 | i = 0; 18 | while (src[i] && (len_d + i + 1 < size)) 19 | { 20 | dest[len_d + i] = src[i]; 21 | i++; 22 | } 23 | dest[len_d + i] = 0; 24 | } 25 | return (len_d + len_s); 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | /* copia los primeros(size) de caracteres de "src" en "dest" */ 2 | #include "libft.h" 3 | 4 | size_t ft_strlcpy(char *dest, const char *src, size_t size) 5 | { 6 | size_t i; 7 | 8 | i = 0; 9 | if (size) 10 | { 11 | while (src[i] && i < (size - 1)) 12 | { 13 | dest[i] = src[i]; 14 | i++; 15 | } 16 | dest[i] = 0; 17 | } 18 | return (ft_strlen(src)); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* cuenta la longitud del string (sin el nulo) */ 2 | #include "libft.h" 3 | 4 | size_t ft_strlen(const char *str) 5 | { 6 | size_t i; 7 | 8 | i = 0; 9 | while (str[i]) 10 | i++; 11 | return (i); 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strmapi.c: -------------------------------------------------------------------------------- 1 | /* asigna MD a una cadena que realiza una operacion "f" con cada caracter 2 | de la cadena "s" */ 3 | #include "libft.h" 4 | 5 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) 6 | { 7 | size_t i; 8 | char *str; 9 | 10 | i = ft_strlen(s); 11 | str = (char *)malloc(sizeof(char) * (i + 1)); 12 | if (!str) 13 | return (NULL); 14 | str[i] = 0; 15 | while (i--) 16 | str[i] = f(i, s[i]); 17 | return (str); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* compara los primeros(size) de caracteres de las cadenas "s1" y "s2" */ 2 | #include "libft.h" 3 | 4 | int ft_strncmp(const char *s1, const char *s2, size_t size) 5 | { 6 | size_t i; 7 | 8 | i = 0; 9 | while (size--) 10 | { 11 | if (s1[i] != s2[i] || s1[i] == 0 || s2[i] == 0) 12 | return ((unsigned char)s1[i] - (unsigned char)s2[i]); 13 | i++; 14 | } 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strnstr.c: -------------------------------------------------------------------------------- 1 | /* buscar la primera aparicion de la subcadena(needle) en la cadena "haystack" 2 | hasta los primeros (size) de valores */ 3 | #include "libft.h" 4 | 5 | char *ft_strnstr(const char *haystack, const char *needle, size_t size) 6 | { 7 | size_t i; 8 | 9 | i = ft_strlen(needle); 10 | if (!(*needle)) 11 | return ((char *)haystack); 12 | while (*haystack && size-- >= i) 13 | { 14 | if (*haystack == *needle && ft_strncmp(haystack, needle, i) == 0) 15 | return ((char *)haystack); 16 | haystack++; 17 | } 18 | return (NULL); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strrchr.c: -------------------------------------------------------------------------------- 1 | /* busca la ultima aparicion del caracter "c" en la cadena "str" */ 2 | #include "libft.h" 3 | 4 | char *ft_strrchr(const char *str, int c) 5 | { 6 | size_t i; 7 | 8 | i = ft_strlen(str) + 1; 9 | while (i--) 10 | { 11 | if (str[i] == (char)c) 12 | return ((char *)&str[i]); 13 | } 14 | return (NULL); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_strtrim.c: -------------------------------------------------------------------------------- 1 | /* devuelve la cadena "s1" sin los caracteres "set" */ 2 | #include "libft.h" 3 | 4 | char *ft_strtrim(char const *s1, char const *set) 5 | { 6 | size_t i; 7 | 8 | if (!s1 || !set) 9 | return (NULL); 10 | while (ft_strchr(set, *s1) && *s1) 11 | s1++; 12 | i = ft_strlen(s1); 13 | while (ft_strchr(set, s1[i]) && i != 0) 14 | i--; 15 | return (ft_substr(s1, 0, i + 1)); 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_substr.c: -------------------------------------------------------------------------------- 1 | /* asigna MD a una string creada a partir del indice (start) de "s" 2 | con la longitud "len" */ 3 | #include "libft.h" 4 | 5 | char *ft_substr(char const *s, unsigned int start, size_t len) 6 | { 7 | char *substr; 8 | 9 | if (!s) 10 | return (NULL); 11 | if (ft_strlen(s) < start) 12 | return (ft_strdup("")); 13 | if (len > ft_strlen(s + start)) 14 | len = ft_strlen(s + start); 15 | substr = malloc(sizeof(char) * (len + 1)); 16 | if (!substr) 17 | return (NULL); 18 | ft_strlcpy(substr, s + start, len + 1); 19 | return (substr); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_tolower.c: -------------------------------------------------------------------------------- 1 | /* convierte el caracter "c" en minuscula */ 2 | #include "libft.h" 3 | 4 | int ft_tolower(int c) 5 | { 6 | if (c >= 'A' && c <= 'Z') 7 | c += 32; 8 | return (c); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_0/libft/src/ft_toupper.c: -------------------------------------------------------------------------------- 1 | /* convierte el caracter "c" en mayuscula */ 2 | #include "libft.h" 3 | 4 | int ft_toupper(int c) 5 | { 6 | if (c >= 'a' && c <= 'z') 7 | c -= 32; 8 | return (c); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_1/Born2beroot/assets/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/Born2beroot/assets/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_1/Born2beroot/assets/header_bor2beroot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/Born2beroot/assets/header_bor2beroot.png -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/ft_printf/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/assets/header_ft_printf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/ft_printf/assets/header_ft_printf.png -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_atoi.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_atoi(const char *str) 4 | { 5 | long atoi; 6 | int sign; 7 | 8 | atoi = 0; 9 | sign = 1; 10 | while ((*str >= 9 && *str <= 13) || *str == 32) 11 | str++; 12 | if (*str == 45 || *str == 43) 13 | { 14 | if (*str == 45) 15 | sign = -1; 16 | str++; 17 | } 18 | while (ft_isdigit(*str)) 19 | { 20 | atoi *= 10; 21 | atoi += *str - 48; 22 | str++; 23 | } 24 | return (atoi * sign); 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_bzero.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_bzero(void *str, size_t size) 4 | { 5 | size_t i; 6 | char *s; 7 | 8 | i = 0; 9 | s = (char *)str; 10 | while (i < size) 11 | s[i++] = 0; 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_calloc.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void *ft_calloc(size_t num, size_t size) 4 | { 5 | void *p; 6 | 7 | p = malloc(num * size); 8 | if (!p) 9 | return (NULL); 10 | ft_bzero(p, (num * size)); 11 | return (p); 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_isalnum.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_isalnum(int c) 4 | { 5 | return (ft_isalpha(c) || ft_isdigit(c)); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_isalpha.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_isalpha(int c) 4 | { 5 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_isascii.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_isascii(int c) 4 | { 5 | return (c >= 0 && c <= 127); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_isdigit.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_isdigit(int c) 4 | { 5 | return (c >= 48 && c <= 57); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_isprint.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_isprint(int c) 4 | { 5 | return (c >= 32 && c <= 126); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_itoa.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | size_t len_int(int n) 4 | { 5 | size_t len; 6 | 7 | len = 0; 8 | if (n <= 0) 9 | len++; 10 | while (n != 0) 11 | { 12 | len++; 13 | n /= 10; 14 | } 15 | return (len); 16 | } 17 | 18 | char *ft_itoa(int n) 19 | { 20 | char *str; 21 | size_t len; 22 | long long nl; 23 | 24 | nl = n; 25 | len = len_int(nl); 26 | str = (char *)malloc(sizeof(char) * (len + 1)); 27 | if (!str) 28 | return (NULL); 29 | if (nl < 0) 30 | { 31 | str[0] = '-'; 32 | nl *= -1; 33 | } 34 | str[len] = 0; 35 | str[--len] = (nl % 10) + '0'; 36 | nl /= 10; 37 | while (nl != 0 && len--) 38 | { 39 | str[len] = (nl % 10) + '0'; 40 | nl /= 10; 41 | } 42 | return (str); 43 | } 44 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstadd_back_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_lstadd_back(t_list **lst, t_list *new) 4 | { 5 | if (*lst) 6 | (ft_lstlast(*lst))->next = new; 7 | else 8 | *lst = new; 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstadd_front_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_lstadd_front(t_list **lst, t_list *new) 4 | { 5 | new->next = *lst; 6 | *lst = new; 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstclear_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_lstclear(t_list **lst, void (*del)(void *)) 4 | { 5 | t_list *aux; 6 | 7 | while (*lst) 8 | { 9 | aux = *lst; 10 | del((*lst)->content); 11 | *lst = (*lst)->next; 12 | free(aux); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstdelone_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_lstdelone(t_list *lst, void (*del)(void *)) 4 | { 5 | (*del)(lst->content); 6 | free(lst); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstiter_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_lstiter(t_list *lst, void (*f)(void *)) 4 | { 5 | while (lst) 6 | { 7 | f(lst->content); 8 | lst = lst->next; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstlast_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | t_list *ft_lstlast(t_list *lst) 4 | { 5 | if (!lst) 6 | return (NULL); 7 | while (lst->next) 8 | lst = lst->next; 9 | return (lst); 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstmap_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) 4 | { 5 | t_list *newlst; 6 | t_list *newel; 7 | 8 | if (!f || !del) 9 | return (NULL); 10 | newlst = NULL; 11 | while (lst) 12 | { 13 | newel = ft_lstnew(f(lst->content)); 14 | if (!newel) 15 | { 16 | ft_lstclear(&lst, del); 17 | return (NULL); 18 | } 19 | ft_lstadd_back(&newlst, newel); 20 | lst = lst->next; 21 | } 22 | return (newlst); 23 | } 24 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstnew_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | t_list *ft_lstnew(void *content) 4 | { 5 | t_list *new; 6 | 7 | new = malloc(sizeof(t_list)); 8 | if (!new) 9 | return (NULL); 10 | new->content = content; 11 | new->next = NULL; 12 | return (new); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_lstsize_bonus.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_lstsize(t_list *lst) 4 | { 5 | int size; 6 | 7 | size = 0; 8 | while (lst) 9 | { 10 | lst = lst->next; 11 | size++; 12 | } 13 | return (size); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_memchr.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void *ft_memchr(const void *str, int c, size_t size) 4 | { 5 | size_t i; 6 | unsigned char *pstr; 7 | 8 | i = 0; 9 | pstr = (unsigned char *)str; 10 | while (size--) 11 | { 12 | if (pstr[i] == (unsigned char)c) 13 | return (&pstr[i]); 14 | i++; 15 | } 16 | return (NULL); 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_memcmp.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_memcmp(const void *s1, const void *s2, size_t size) 4 | { 5 | unsigned char *str1; 6 | unsigned char *str2; 7 | size_t i; 8 | 9 | str1 = (unsigned char *)s1; 10 | str2 = (unsigned char *)s2; 11 | i = 0; 12 | while (size--) 13 | { 14 | if (str1[i] != str2[i]) 15 | return (str1[i] - str2[i]); 16 | i++; 17 | } 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_memcpy.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void *ft_memcpy(void *dest, const void *src, size_t size) 4 | { 5 | char *d; 6 | char *s; 7 | 8 | d = (char *)dest; 9 | s = (char *)src; 10 | if (!dest && !src) 11 | return (NULL); 12 | while (size--) 13 | *d++ = *s++; 14 | return (dest); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_memmove.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void *ft_memmove(void *dest, const void *src, size_t size) 4 | { 5 | char *d; 6 | char *s; 7 | 8 | d = (char *)dest; 9 | s = (char *)src; 10 | if (!dest && !src) 11 | return (NULL); 12 | if (d < s) 13 | ft_memcpy(d, s, size); 14 | else 15 | { 16 | while (size--) 17 | d[size] = s[size]; 18 | } 19 | return (d); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_memset.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void *ft_memset(void *str, int c, size_t size) 4 | { 5 | size_t i; 6 | char *pstr; 7 | 8 | i = 0; 9 | pstr = (char *)str; 10 | while (i < size) 11 | pstr[i++] = c; 12 | return (str); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_putchar_fd.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_putchar_fd(char c, int fd) 4 | { 5 | write(fd, &c, 1); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_putendl_fd.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_putendl_fd(char *s, int fd) 4 | { 5 | if (!s) 6 | return ; 7 | ft_putstr_fd(s, fd); 8 | ft_putchar_fd('\n', fd); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_putnbr_fd(int n, int fd) 4 | { 5 | long nb; 6 | 7 | nb = n; 8 | if (nb < 0) 9 | { 10 | ft_putchar_fd('-', fd); 11 | nb *= -1; 12 | } 13 | if (nb >= 10) 14 | { 15 | ft_putnbr_fd(nb / 10, fd); 16 | ft_putnbr_fd(nb % 10, fd); 17 | } 18 | else 19 | ft_putchar_fd(nb + '0', fd); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_putstr_fd.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_putstr_fd(char *s, int fd) 4 | { 5 | if (!s) 6 | return ; 7 | write(fd, s, ft_strlen(s)); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strchr.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strchr(const char *str, int c) 4 | { 5 | while (*str != (char)c) 6 | { 7 | if (!(*str)) 8 | return (NULL); 9 | str++; 10 | } 11 | return ((char *)str); 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strdup.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strdup(const char *str) 4 | { 5 | int len; 6 | char *copy; 7 | 8 | len = ft_strlen(str); 9 | copy = (char *)malloc(sizeof(char) * (len + 1)); 10 | if (!copy) 11 | return (NULL); 12 | while (len >= 0) 13 | { 14 | copy[len] = str[len]; 15 | len--; 16 | } 17 | return (copy); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_striteri.c: -------------------------------------------------------------------------------- 1 | include "libft.h" 2 | 3 | void 4 | ft_striteri(char *s, void (*f)(unsigned int, char *)) 5 | { 6 | size_t i; 7 | 8 | i = ft_strlen(s); 9 | while (i--) 10 | f(i, &s[i]); 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strjoin.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strjoin(char const *s1, char const *s2) 4 | { 5 | char *str; 6 | size_t str_len; 7 | size_t i; 8 | 9 | str_len = (ft_strlen(s1) + ft_strlen(s2) + 1); 10 | str = (char *)malloc(sizeof(char) * str_len); 11 | if (!s1 || !s2 || !str) 12 | return (NULL); 13 | i = 0; 14 | while (*s1) 15 | str[i++] = *s1++; 16 | while (*s2) 17 | str[i++] = *s2++; 18 | str[i] = 0; 19 | return (str); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strlcat.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | size_t ft_strlcat(char *dest, const char *src, size_t size) 4 | { 5 | size_t len_d; 6 | size_t len_s; 7 | size_t i; 8 | 9 | len_d = ft_strlen(dest); 10 | len_s = ft_strlen(src); 11 | if (len_d >= size) 12 | return (len_s + size); 13 | else if (len_d + 1 < size) 14 | { 15 | i = 0; 16 | while (src[i] && (len_d + i + 1 < size)) 17 | { 18 | dest[len_d + i] = src[i]; 19 | i++; 20 | } 21 | dest[len_d + i] = 0; 22 | } 23 | return (len_d + len_s); 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | size_t ft_strlcpy(char *dest, const char *src, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | if (size) 9 | { 10 | while (src[i] && i < (size - 1)) 11 | { 12 | dest[i] = src[i]; 13 | i++; 14 | } 15 | dest[i] = 0; 16 | } 17 | return (ft_strlen(src)); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strlen.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | size_t ft_strlen(const char *str) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | while (str[i]) 9 | i++; 10 | return (i); 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strmapi.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) 4 | { 5 | size_t i; 6 | char *str; 7 | 8 | i = ft_strlen(s); 9 | str = (char *)malloc(sizeof(char) * (i + 1)); 10 | if (!str) 11 | return (NULL); 12 | str[i] = 0; 13 | while (i--) 14 | str[i] = f(i, s[i]); 15 | return (str); 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_strncmp(const char *s1, const char *s2, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | while (size--) 9 | { 10 | if (s1[i] != s2[i] || s1[i] == 0 || s2[i] == 0) 11 | return ((unsigned char)s1[i] - (unsigned char)s2[i]); 12 | i++; 13 | } 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strnstr.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strnstr(const char *haystack, const char *needle, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = ft_strlen(needle); 8 | if (!(*needle)) 9 | return ((char *)haystack); 10 | while (*haystack && size-- >= i) 11 | { 12 | if (*haystack == *needle && ft_strncmp(haystack, needle, i) == 0) 13 | return ((char *)haystack); 14 | haystack++; 15 | } 16 | return (NULL); 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strrchr.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strrchr(const char *str, int c) 4 | { 5 | size_t i; 6 | 7 | i = ft_strlen(str) + 1; 8 | while (i--) 9 | { 10 | if (str[i] == (char)c) 11 | return ((char *)&str[i]); 12 | } 13 | return (NULL); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_strtrim.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_strtrim(char const *s1, char const *set) 4 | { 5 | size_t i; 6 | 7 | if (!s1 || !set) 8 | return (NULL); 9 | while (ft_strchr(set, *s1) && *s1) 10 | s1++; 11 | i = ft_strlen(s1); 12 | while (ft_strchr(set, s1[i]) && i != 0) 13 | i--; 14 | return (ft_substr(s1, 0, i + 1)); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_substr.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | char *ft_substr(char const *s, unsigned int start, size_t len) 4 | { 5 | char *substr; 6 | 7 | if (!s) 8 | return (NULL); 9 | if (ft_strlen(s) < start) 10 | return (ft_strdup("")); 11 | if (len > ft_strlen(s + start)) 12 | len = ft_strlen(s + start); 13 | substr = malloc(sizeof(char) * (len + 1)); 14 | if (!substr) 15 | return (NULL); 16 | ft_strlcpy(substr, s + start, len + 1); 17 | return (substr); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_tolower.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_tolower(int c) 4 | { 5 | if (c >= 'A' && c <= 'Z') 6 | c += 32; 7 | return (c); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_toupper.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | int ft_toupper(int c) 4 | { 5 | if (c >= 'a' && c <= 'z') 6 | c -= 32; 7 | return (c); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/libft/ft_toupper_str.c: -------------------------------------------------------------------------------- 1 | #include "libft.h" 2 | 3 | void ft_toupper_str(char *str) 4 | { 5 | int len; 6 | int i; 7 | 8 | i = 0; 9 | len = ft_strlen(str); 10 | while (len--) 11 | { 12 | str[i] = ft_toupper(str[i]); 13 | i++; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf/src/ft_printf.c: -------------------------------------------------------------------------------- 1 | #include "../inc/ft_printf.h" 2 | 3 | int ft_printf(const char *str, ...) 4 | { 5 | t_block b; 6 | 7 | ft_bzero(&b, sizeof(b)); 8 | va_start(b.ap, str); 9 | while (str[b.i]) 10 | { 11 | if (str[b.i] != '%') 12 | b.ret += write(1, &str[b.i++], 1); 13 | else 14 | { 15 | (b.i)++; 16 | reset_block(&b); 17 | ft_check_flags(str, &b); 18 | ft_check_types(str, &b); 19 | } 20 | } 21 | va_end(b.ap); 22 | reset_block(&b); 23 | return (b.ret); 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_1/ft_printf/ft_printf_bonus/libft/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /42-cursus/circle_1/get_next_line/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/get_next_line/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_1/get_next_line/assets/header_get_next_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_1/get_next_line/assets/header_get_next_line.png -------------------------------------------------------------------------------- /42-cursus/circle_1/get_next_line/bonus/get_next_line_bonus.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_NEXT_LINE_BONUS_H 2 | # define GET_NEXT_LINE_BONUS_H 3 | 4 | # include 5 | # include 6 | # include 7 | # include 8 | # include 9 | 10 | # ifndef BUFFER_SIZE 11 | # define BUFFER_SIZE 42 12 | # endif 13 | 14 | char *get_next_line(int fd); 15 | int ft_strlen(char *s); 16 | char *ft_strchr(char *s, int c); 17 | void *ft_calloc(size_t count, size_t size); 18 | char *ft_strjoin(char *s1, char *s2); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_1/get_next_line/inc/get_next_line.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_NEXT_LINE_H 2 | # define GET_NEXT_LINE_H 3 | 4 | # include 5 | # include 6 | # include 7 | # include 8 | 9 | # ifndef BUFFER_SIZE 10 | # define BUFFER_SIZE 42 11 | # endif 12 | 13 | char *get_next_line(int fd); 14 | int ft_strlen(char *s); 15 | char *ft_strchr(char *s, int c); 16 | void *ft_calloc(size_t count, size_t size); 17 | char *ft_strjoin(char *s1, char *s2); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/assets/exam_rank_02_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/exam_rank_02/assets/exam_rank_02_header.png -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/assets/grademe_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/exam_rank_02/assets/grademe_01.png -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/first_word/first_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void first_word(char *str) 4 | { 5 | while (*str == ' ' || *str == '\t') 6 | str++; 7 | while (*str && *str != '\t' && *str != ' ') 8 | { 9 | write(1, str, 1); 10 | str++; 11 | } 12 | } 13 | 14 | int main (int ac, char **av) 15 | { 16 | if (ac == 2) 17 | first_word(av[1]); 18 | write(1, "\n", 1); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_putstr/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_putstr 3 | Expected files : ft_putstr.c 4 | Allowed functions: write 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that displays a string on the standard output. 8 | 9 | The pointer passed to the function contains the address of the string's first 10 | character. 11 | 12 | Your function must be declared as follows: 13 | 14 | void ft_putstr(char *str); 15 | ``` 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_putstr/ft_putstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) 4 | { 5 | while (*str) 6 | write(1, str++, 1); 7 | } 8 | 9 | //MAIN 10 | /*int main(int ac, char **av){ 11 | if (ac == 2) 12 | ft_putstr(av[1]); 13 | write(1, "\n", 1); 14 | return 0; 15 | }*/ 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_strcpy/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strcpy 3 | Expected files : ft_strcpy.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Reproduce the behavior of the function strcpy (man strcpy). 8 | 9 | Your function must be declared as follows: 10 | 11 | char *ft_strcpy(char *s1, char *s2); 12 | ``` 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_strcpy/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | char *ft_strcpy(char *s1, char *s2) 2 | { 3 | int i = 0; 4 | 5 | while (s2[i]) 6 | { 7 | s1[i] = s2[i]; 8 | i++; 9 | } 10 | s1[i] = 0; 11 | return s1; 12 | } 13 | 14 | //MAIN 15 | /*#include 16 | int main(){ 17 | char s1[] = ""; 18 | char s2[] = "origen en destino"; 19 | printf("%s\n", ft_strcpy(s1, s2)); 20 | }*/ 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_strlen/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strlen 3 | Expected files : ft_strlen.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that returns the length of a string. 8 | 9 | Your function must be declared as follows: 10 | 11 | int ft_strlen(char *str); 12 | ``` 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_strlen/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str){ 2 | int i; 3 | for (i = 0; str[i]; i++); 4 | return i; 5 | } 6 | 7 | //NORME FORM 8 | /*int ft_strlen(char *str) 9 | { 10 | int i = 0; 11 | 12 | while (str[i]) 13 | i++; 14 | return (i); 15 | }*/ 16 | 17 | //MAIN 18 | /*#include 19 | int main(int ac, char **av){ 20 | if (ac == 2) 21 | printf("%i\n", ft_strlen(av[1])); 22 | return 0; 23 | }*/ 24 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_swap/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_swap 3 | Expected files : ft_swap.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that swaps the contents of two integers the adresses of which 8 | are passed as parameters. 9 | 10 | Your function must be declared as follows: 11 | 12 | void ft_swap(int *a, int *b); 13 | ``` 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/ft_swap/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int tmp = *a; 4 | *a = *b; 5 | *b = tmp; 6 | } 7 | 8 | //MAIN 9 | /*#include 10 | int main(){ 11 | int a = 42; 12 | int b = 16; 13 | 14 | printf("a = %i | b = %i\n", a, b); 15 | 16 | ft_swap(&a, &b); 17 | 18 | printf("a = %i | b = %i\n", a, b); 19 | }*/ 20 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/repeat_alpha/repeat_alpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print_repeat_char(char c) 4 | { 5 | int cantidad; 6 | 7 | if (c >= 'a' && c <= 'z') 8 | cantidad = c - 'a' + 1; 9 | else if (c >= 'A' && c <= 'Z') 10 | cantidad = c - 'A' + 1; 11 | while (cantidad--) 12 | write(1, &c, 1); 13 | } 14 | 15 | void repeat_alpha(char *str) 16 | { 17 | while (*str) 18 | { 19 | if ((*str >= 'a' && *str <= 'z') || (*str >= 'A' && *str <= 'Z')) 20 | print_repeat_char(*str); 21 | else 22 | write(1, str, 1); 23 | str++; 24 | } 25 | } 26 | 27 | int main (int ac, char **av) 28 | { 29 | if (ac == 2) 30 | repeat_alpha(av[1]); 31 | write(1, "\n", 1); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/rev_print/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : rev_print 3 | Expected files : rev_print.c 4 | Allowed functions: write 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a program that takes a string, and displays the string in reverse 8 | followed by a newline. 9 | 10 | If the number of parameters is not 1, the program displays a newline. 11 | 12 | Examples: 13 | 14 | $> ./rev_print "zaz" | cat -e 15 | zaz$ 16 | $> ./rev_print "dub0 a POIL" | cat -e 17 | LIOP a 0bud$ 18 | $> ./rev_print | cat -e 19 | $ 20 | ``` 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/rev_print/rev_print.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void rev_print(char *str) 4 | { 5 | int i; 6 | for (i = 0; str[i]; i++); 7 | while (i--) 8 | write(1, &str[i], 1); 9 | } 10 | 11 | int main(int ac, char **av){ 12 | if (ac == 2) 13 | rev_print(av[1]); 14 | write(1, "\n", 1); 15 | return 0; 16 | } 17 | 18 | // NORME FORM 19 | /*int main(int argc, char *argv[]) 20 | { 21 | int i = 0; 22 | 23 | if (argc == 2) 24 | { 25 | while (argv[1][i]) 26 | i++; 27 | while (i--) 28 | write(1, &argv[1][i], 1); 29 | } 30 | write(1, "\n", 1); 31 | return (0); 32 | }*/ 33 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_0/rotone/rotone.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void rotone(char *s) 4 | { 5 | while (*s) 6 | { 7 | if ((*s >= 'a' && *s <='y') || (*s >= 'A' && *s <= 'Y')) 8 | *s += 1; 9 | else if (*s == 'z' || *s == 'Z') 10 | *s -= 25; 11 | write(1, s, 1); 12 | s++; 13 | } 14 | } 15 | 16 | int main(int ac, char **av){ 17 | if (ac == 2) 18 | rotone(av[1]); 19 | write(1, "\n", 1); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/camel_to_snake/camel_to_snake.c: -------------------------------------------------------------------------------- 1 | #include //write 2 | #include //malloc, realloc 3 | 4 | void camel_to_snake(char *s) 5 | { 6 | // no tener en cuenta los espacios del principio 7 | while (*s == ' ' || *s == '\t') 8 | s++; 9 | // cuando encuentre una upper imprima '_' y la cambia a lower 10 | while (*s) 11 | { 12 | if (*s >= 'A' && *s <= 'Z') 13 | { 14 | *s += 32; 15 | write(1, "_", 1); 16 | } 17 | write(1, s, 1); 18 | s++; 19 | } 20 | } 21 | 22 | int main(int ac, char **av) 23 | { 24 | if (ac == 2) 25 | camel_to_snake(av[1]); 26 | write(1, "\n", 1); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_atoi/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_atoi 3 | Expected files : ft_atoi.c Allowed functions: None -------------------------------------------------------------------------------- Write a function that converts the string argument str to an integer (type int) 4 | and returns it. 5 | 6 | It works much like the standard atoi(const char *str) function, see the man. 7 | 8 | Your function must be declared as follows: 9 | 10 | int ft_atoi(const char *str); 11 | 12 | ``` 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_atoi/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(const char *str) 2 | { 3 | int result = 0; 4 | int sign = 1; 5 | 6 | while ((*str >= 9 && *str <= 13) || *str == 32) 7 | str++; 8 | if (*str == '-' || *str == '+') 9 | { 10 | if (*str == '-') 11 | sign = -1; 12 | str++; 13 | } 14 | while (*str >= '0' && *str <= '9') 15 | { 16 | result *= 10; 17 | result += *str - '0'; 18 | str++; 19 | } 20 | return (result * sign); 21 | } 22 | 23 | //MAIN 24 | /*#include 25 | int main(int ac, char **av) 26 | { 27 | if (ac == 2) 28 | printf("%i\n", ft_atoi(av[1])); 29 | return 0; 30 | }*/ 31 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strcmp/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strcmp 3 | Expected files : ft_strcmp.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Reproduce the behavior of the function strcmp (man strcmp). 8 | 9 | Your function must be declared as follows: 10 | 11 | int ft_strcmp(char *s1, char *s2); 12 | ``` 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strcmp/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | int ft_strcmp(char *s1, char *s2) 2 | { 3 | int i = 0; 4 | 5 | while(s1[i] && s2[i] && s1[i] == s2[i]) 6 | i++; 7 | return s1[i] - s2[i]; 8 | } 9 | 10 | /*#include 11 | int main(int ac, char **av) 12 | { 13 | if (ac == 3) 14 | printf("%i", ft_strcmp(av[1], av[2])); 15 | printf("\n"); 16 | return 0; 17 | }*/ 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strcspn/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strcspn 3 | Expected files : ft_strcspn.c 4 | Allowed functions: None 5 | --------------------------------------------------------------- 6 | 7 | Reproduce exactly the behavior of the function strcspn 8 | (man strcspn). 9 | 10 | The function should be prototyped as follows: 11 | 12 | size_t ft_strcspn(const char *s, const char *reject); 13 | ``` 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strdup/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strdup 3 | Expected files : ft_strdup.c 4 | Allowed functions: malloc 5 | -------------------------------------------------------------------------------- 6 | 7 | Reproduce the behavior of the function strdup (man strdup). 8 | 9 | Your function must be declared as follows: 10 | 11 | char *ft_strdup(char *src); 12 | ``` 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strdup/ft_strdup.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *ft_strdup(char *src) 4 | { 5 | int i = 0; 6 | 7 | while (src[i]) 8 | i++; 9 | char *str = (char *)malloc(sizeof(*str) * (i + 1)); 10 | if (str == NULL) 11 | return NULL; 12 | i = 0; 13 | while (src[i]) 14 | { 15 | str[i] = src[i]; 16 | i++; 17 | } 18 | src[i] = 0; 19 | return str; 20 | } 21 | 22 | //MAIN 23 | /*#include 24 | int main(int ac, char **av) 25 | { 26 | char *str = ft_strdup(av[1]); 27 | 28 | if (ac == 2) 29 | printf("%s", str); 30 | printf("\n"); 31 | free(str); 32 | return 0; 33 | }*/ 34 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strpbrk/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strpbrk 3 | Expected files : ft_strpbrk.c 4 | Allowed functions: None 5 | --------------------------------------------------------------- 6 | 7 | Reproduce exactly the behavior of the function strpbrk 8 | (man strpbrk). 9 | 10 | The function should be prototyped as follows: 11 | 12 | char *ft_strpbrk(const char *s1, const char *s2); 13 | ``` 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strpbrk/ft_strpbrk.c: -------------------------------------------------------------------------------- 1 | #include //NULL 2 | 3 | char *ft_strpbrk(const char *s1, const char *s2) 4 | { 5 | int i; 6 | 7 | if (!s1 || !s2) 8 | return NULL; 9 | while (*s1) 10 | { 11 | i = 0; 12 | while (s2[i]) 13 | { 14 | if (*s1 == s2[i]) 15 | return (char *) s1; 16 | i++; 17 | } 18 | s1++; 19 | } 20 | return NULL; 21 | } 22 | 23 | //MAIN 24 | /*#include 25 | #include 26 | int main (int ac, char **av) 27 | { 28 | if (ac == 3) 29 | { 30 | printf("%s\n", ft_strpbrk(av[1], av[2])); 31 | printf("%s\n", strpbrk(av[1], av[2])); 32 | } 33 | return 0; 34 | }*/ 35 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strrev/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strrev 3 | Expected files : ft_strrev.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that reverses (in-place) a string. 8 | 9 | It must return its parameter. 10 | 11 | Your function must be declared as follows: 12 | 13 | char *ft_strrev(char *str); 14 | ``` 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/ft_strspn/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_strspn 3 | Expected files : ft_strspn.c 4 | Allowed functions: None 5 | --------------------------------------------------------------- 6 | 7 | Reproduce exactly the behavior of the strspn function 8 | (man strspn). 9 | 10 | The function should be prototyped as follows: 11 | 12 | size_t ft_strspn(const char *s, const char *accept); 13 | ``` 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/inter/inter.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int inter(char *str, char c, int len) 4 | { 5 | int i = 0; 6 | 7 | while (str[i] && (i < len || len == -1)) 8 | if (str[i++] == c) 9 | return 1; 10 | return 0; 11 | } 12 | 13 | int main(int ac, char **av) 14 | { 15 | int i = 0; 16 | 17 | if (ac == 3) 18 | { 19 | while (av[1][i]) 20 | { 21 | if (!inter(av[1], av[1][i], i) && inter(av[2], av[1][i], -1)) 22 | write(1, &av[1][i], 1); 23 | i++; 24 | } 25 | } 26 | write(1, "\n", 1); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/is_power_of_2/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : is_power_of_2 3 | Expected files : is_power_of_2.c 4 | Allowed functions: None 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that determines if a given number is a power of 2. 8 | 9 | This function returns 1 if the given number is a power of 2, otherwise it returns 0. 10 | 11 | Your function must be declared as follows: 12 | 13 | int is_power_of_2(unsigned int n); 14 | ``` 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/is_power_of_2/is_power_of_2.c: -------------------------------------------------------------------------------- 1 | int is_power_of_2(unsigned int n) 2 | { 3 | return ((n & (-n)) == n ? 1 : 0); 4 | } 5 | 6 | //OTHER FORM (la considero mejor que la primera) 7 | /*int is_power_of_2(unsigned int n) 8 | { 9 | return ((n & (n - 1)) == 0); 10 | }*/ 11 | 12 | //MAIN 13 | /*#include 14 | #include 15 | int main(int ac, char **av) 16 | { 17 | if (ac == 2) 18 | { 19 | int n = atoi(av[1]); 20 | if (is_power_of_2(n)) 21 | printf("%i\n%i SI es potencia de 2 ;)\n", is_power_of_2(n), n); 22 | else 23 | printf("%i\n%i NO es potencia de 2 :(\n", is_power_of_2(n), n); 24 | } 25 | return 0; 26 | }*/ 27 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/max/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : max 3 | Expected files : max.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write the following function: 8 | 9 | int max(int* tab, unsigned int len); 10 | 11 | The first parameter is an array of int, the second is the number of elements in 12 | the array. 13 | 14 | The function returns the largest number found in the array. 15 | 16 | If the array is empty, the function returns 0. 17 | ``` 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/max/max.c: -------------------------------------------------------------------------------- 1 | int max(int* tab, unsigned int len) 2 | { 3 | unsigned int i = 0, result = tab[i]; 4 | 5 | if (len == 0) 6 | return 0; 7 | for (; i < len; i++) { 8 | if (result < tab[i]) 9 | result = tab[i]; 10 | } 11 | return result; 12 | } 13 | 14 | //NORM FORM 15 | /*int max(int* tab, unsigned int len) 16 | { 17 | unsigned int i = 0; 18 | unsigned int result = tab[i]; 19 | 20 | if (len == 0) 21 | return 0; 22 | while (i < len) 23 | { 24 | if (tab[i] > result) 25 | result = tab[i]; 26 | i++; 27 | } 28 | return result; 29 | }*/ 30 | 31 | //MAIN 32 | /*#include 33 | int main(){ 34 | unsigned int len = 5; 35 | int tab[5] = {3, 2, 8, 4, 0}; 36 | printf("%i\n", max(tab, len)); 37 | }*/ 38 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/print_bits/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : print_bits 3 | Expected files : print_bits.c 4 | Allowed functions: write 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that takes a byte, and prints it in binary WITHOUT A NEWLINE 8 | AT THE END. 9 | 10 | Your function must be declared as follows: 11 | 12 | void print_bits(unsigned char octet); 13 | 14 | Example, if you pass 2 to print_bits, it will print "00000010" 15 | ``` 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/print_bits/print_bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print_bits(unsigned char octet) 4 | { 5 | int i = 8; 6 | unsigned char bit; 7 | 8 | while(i--) 9 | { 10 | bit = (octet >> i & 1) + '0'; 11 | write(1, &bit, 1); 12 | } 13 | } 14 | 15 | //MAIN 16 | /*#include 17 | int main(int ac, char **av) 18 | { 19 | unsigned char octet = atoi(av[1]); 20 | 21 | if (ac == 2) 22 | print_bits(octet); 23 | write(1, "\n", 1); 24 | return 0; 25 | }*/ 26 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/reverse_bits/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : reverse_bits 3 | Expected files : reverse_bits.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that takes a byte, reverses it, bit by bit (like the 8 | example) and returns the result. 9 | 10 | Your function must be declared as follows: 11 | 12 | unsigned char reverse_bits(unsigned char octet); 13 | 14 | Example: 15 | 16 | 1 byte 17 | _____________ 18 | 0010 0110 19 | || 20 | \/ 21 | 0110 0100 22 | ``` 23 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/swap_bits/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : swap_bits 3 | Expected files : swap_bits.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that takes a byte, swaps its halves (like the example) and 8 | returns the result. 9 | 10 | Your function must be declared as follows: 11 | 12 | unsigned char swap_bits(unsigned char octet); 13 | 14 | Example: 15 | 16 | 1 byte 17 | _____________ 18 | 0100 | 0001 19 | \ / 20 | / \ 21 | 0001 | 0100 22 | ``` 23 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/swap_bits/swap_bits.c: -------------------------------------------------------------------------------- 1 | unsigned char swap_bits(unsigned char octet) { 2 | return ((octet >> 4) | (octet << 4)); 3 | } 4 | 5 | //MAIN 6 | /*#include 7 | #include 8 | int main(int ac, char **av) 9 | { 10 | if (ac == 2) 11 | { 12 | unsigned char byte_invertido; 13 | unsigned char byte = atoi(av[1]); 14 | 15 | printf("Byte original: %u\n", byte); // Imprime el byte original 16 | byte_invertido = swap_bits(byte); // Llama a la función reverse_bits 17 | printf("Byte invertido: %u\n", byte_invertido); // Imprime el byte invertido 18 | } 19 | return (0); 20 | }*/ 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_1/wdmatch/wdmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) { 4 | for (int i = 0; str[i]; i++) 5 | write(1, &str[i], 1); 6 | } 7 | 8 | int main(int ac, char **av) 9 | { 10 | int i = 0, j = 0; 11 | 12 | if (ac == 3) 13 | { 14 | while (av[2][j]) 15 | if (av[2][j++] == av[1][i]) 16 | i++; 17 | if (!av[1][i]) //verifica si ha llegado al final de la cadena 18 | ft_putstr(av[1]); 19 | } 20 | write(1, "\n", 1); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/add_prime_sum/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : add_prime_sum 3 | Expected files : add_prime_sum.c 4 | Allowed functions: write, exit 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a program that takes a positive integer as argument and displays the sum 8 | of all prime numbers inferior or equal to it followed by a newline. 9 | 10 | If the number of arguments is not 1, or the argument is not a positive number, 11 | just display 0 followed by a newline. 12 | 13 | Yes, the examples are right. 14 | 15 | Examples: 16 | 17 | $>./add_prime_sum 5 18 | 10 19 | $>./add_prime_sum 7 | cat -e 20 | 17$ 21 | $>./add_prime_sum | cat -e 22 | 0$ 23 | $> 24 | ``` 25 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/epur_str/epur_str.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char const *argv[]) 4 | { 5 | int i; 6 | int flg; 7 | 8 | if (argc == 2) 9 | { 10 | i = 0; 11 | while (argv[1][i] == ' ' || argv[1][i] == '\t') 12 | i += 1; 13 | while (argv[1][i]) 14 | { 15 | if (argv[1][i] == ' ' || argv[1][i] == '\t') 16 | flg = 1; 17 | if (!(argv[1][i] == ' ' || argv[1][i] == '\t')) 18 | { 19 | if (flg) 20 | write(1, " ", 1); 21 | flg = 0; 22 | write(1, &argv[1][i], 1); 23 | } 24 | i += 1; 25 | } 26 | } 27 | write(1, "\n", 1); 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/ft_list_size/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_list_size 3 | Expected files : ft_list_size.c, ft_list.h 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that returns the number of elements in the linked list that's 8 | passed to it. 9 | 10 | It must be declared as follows: 11 | 12 | int ft_list_size(t_list *begin_list); 13 | 14 | You must use the following structure, and turn it in as a file called 15 | ft_list.h: 16 | 17 | typedef struct s_list 18 | { 19 | struct s_list *next; 20 | void *data; 21 | } t_list; 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/ft_list_size/ft_list.h: -------------------------------------------------------------------------------- 1 | typedef struct s_list 2 | { 3 | struct s_list *next; 4 | void *data; 5 | } t_list; 6 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/ft_list_size/ft_list_size.c: -------------------------------------------------------------------------------- 1 | #include "ft_list.h" 2 | 3 | int ft_list_size(t_list *begin_list) 4 | { 5 | if (begin_list == 0) 6 | return (0); 7 | else 8 | return (1 + ft_list_size(begin_list->next)); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/ft_range/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int *ft_range(int start, int end) 4 | { 5 | int i = 0; 6 | int len = abs((end - start)) + 1; 7 | int *res = (int *)malloc(sizeof(int) * len); 8 | 9 | while (i < len) 10 | { 11 | if (start < end) 12 | { 13 | res[i] = start; 14 | start++; 15 | i++; 16 | } 17 | else 18 | { 19 | res[i] = start; 20 | start--; 21 | i++; 22 | } 23 | } 24 | return (res); 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/hidenp/hidenp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int i = 0; 6 | int j = 0; 7 | 8 | if (argc == 3) 9 | { 10 | while (argv[2][j] && argv[1][i]) 11 | { 12 | if (argv[2][j] == argv[1][i]) 13 | i++; 14 | j++; 15 | } 16 | if (argv[1][i] == '\0') 17 | write(1, "1", 1); 18 | else 19 | write(1, "0", 1); 20 | } 21 | write(1, "\n", 1); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/lcm/lcm.c: -------------------------------------------------------------------------------- 1 | unsigned int lcm(unsigned int a, unsigned int b) 2 | { 3 | unsigned int n; 4 | 5 | if (a == 0 || b == 0) 6 | return (0); 7 | if (a > b) 8 | n = a; 9 | else 10 | n = b; 11 | while (1) 12 | { 13 | if (n % a == 0 && n % b == 0) 14 | return (n); 15 | ++n; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/paramsum/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : paramsum 3 | Expected files : paramsum.c 4 | Allowed functions: write 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a program that displays the number of arguments passed to it, followed by 8 | a newline. 9 | 10 | If there are no arguments, just display a 0 followed by a newline. 11 | 12 | Example: 13 | 14 | $>./paramsum 1 2 3 5 7 24 15 | 6 16 | $>./paramsum 6 12 24 | cat -e 17 | 3$ 18 | $>./paramsum | cat -e 19 | 0$ 20 | $> 21 | ``` 22 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/paramsum/paramsum.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putnbr(int n){ 4 | char digit; 5 | 6 | if (n >= 10) 7 | ft_putnbr(n / 10); 8 | digit = (n % 10) + '0'; 9 | write(1, &digit, 1); 10 | } 11 | 12 | int main(int ac, char **av){ 13 | (void)av; 14 | 15 | ft_putnbr(ac - 1); 16 | write(1, "\n", 1); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/pgcd/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : pgcd 3 | Expected files : pgcd.c 4 | Allowed functions: printf, atoi, malloc, free 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a program that takes two strings representing two strictly positive 8 | integers that fit in an int. 9 | 10 | Display their highest common denominator followed by a newline (It's always a 11 | strictly positive integer). 12 | 13 | If the number of parameters is not 2, display a newline. 14 | 15 | Examples: 16 | 17 | $> ./pgcd 42 10 | cat -e 18 | 2$ 19 | $> ./pgcd 42 12 | cat -e 20 | 6$ 21 | $> ./pgcd 14 77 | cat -e 22 | 7$ 23 | $> ./pgcd 17 3 | cat -e 24 | 1$ 25 | $> ./pgcd | cat -e 26 | $ 27 | ``` 28 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/pgcd/pgcd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char const *argv[]) 5 | { 6 | int nbr1; 7 | int nbr2; 8 | 9 | if (argc == 3) 10 | { 11 | if ((nbr1 = atoi(argv[1])) > 0 && (nbr2 = atoi(argv[2])) > 0) 12 | { 13 | while (nbr1 != nbr2) 14 | { 15 | if (nbr1 > nbr2) 16 | nbr1 -= nbr2; 17 | else 18 | nbr2 -= nbr1; 19 | } 20 | printf("%d", nbr1); 21 | } 22 | } 23 | printf("\n"); 24 | return (0); 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/print_hex/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : print_hex 3 | Expected files : print_hex.c 4 | Allowed functions: write 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a program that takes a positive (or zero) number expressed in base 10, 8 | and displays it in base 16 (lowercase letters) followed by a newline. 9 | 10 | If the number of parameters is not 1, the program displays a newline. 11 | 12 | Examples: 13 | 14 | $> ./print_hex "10" | cat -e 15 | a$ 16 | $> ./print_hex "255" | cat -e 17 | ff$ 18 | $> ./print_hex "5156454" | cat -e 19 | 4eae66$ 20 | $> ./print_hex | cat -e 21 | $ 22 | ``` 23 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_2/print_hex/print_hex.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int ft_atoi(char *str) 4 | { 5 | int n = 0; 6 | 7 | while (*str != '\0') 8 | { 9 | n = n * 10; 10 | n = n + *str - '0'; 11 | ++str; 12 | } 13 | return (n); 14 | } 15 | 16 | void print_hex(int n) 17 | { 18 | char hex_digits[] = "0123456789abcdef"; 19 | 20 | if (n >= 16) 21 | print_hex(n / 16); 22 | write(1, &hex_digits[n % 16], 1); 23 | } 24 | 25 | int main(int argc, char **argv) 26 | { 27 | if (argc == 2) 28 | print_hex(ft_atoi(argv[1])); 29 | write(1, "\n", 1); 30 | } 31 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/flood_fill/flood_fill.c: -------------------------------------------------------------------------------- 1 | typedef struct s_point 2 | { 3 | int x; 4 | int y; 5 | } t_point; 6 | 7 | void fill(char **tab, t_point size, t_point cur, char to_fill) 8 | { 9 | if (cur.y < 0 || cur.y >= size.y || cur.x < 0 || cur.x >= size.x 10 | || tab[cur.y][cur.x] != to_fill) 11 | return; 12 | 13 | tab[cur.y][cur.x] = 'F'; 14 | fill(tab, size, (t_point){cur.x - 1, cur.y}, to_fill); 15 | fill(tab, size, (t_point){cur.x + 1, cur.y}, to_fill); 16 | fill(tab, size, (t_point){cur.x, cur.y - 1}, to_fill); 17 | fill(tab, size, (t_point){cur.x, cur.y + 1}, to_fill); 18 | } 19 | 20 | void flood_fill(char **tab, t_point size, t_point begin) 21 | { 22 | fill(tab, size, begin, tab[begin.y][begin.x]); 23 | } 24 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/flood_fill/flood_fill.t_point.h: -------------------------------------------------------------------------------- 1 | #ifndef T_POINT_FLOOD_FILL 2 | # define T_POINT_FLOOD_FILL 3 | 4 | typedef struct s_point { 5 | int x; // x : Width | x-axis 6 | int y; // y : Height | y-axis 7 | } t_point; 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/fprime/fprime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | int i; 7 | int number; 8 | 9 | if (argc == 2) 10 | { 11 | i = 1; 12 | number = atoi(argv[1]); 13 | if (number == 1) 14 | printf("1"); 15 | while (number >= ++i) 16 | { 17 | if (number % i == 0) 18 | { 19 | printf("%d", i); 20 | if (number == i) 21 | break ; 22 | printf("*"); 23 | number /= i; 24 | i = 1; 25 | } 26 | } 27 | } 28 | printf("\n"); 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/ft_itoa/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_itoa 3 | Expected files : ft_itoa.c 4 | Allowed functions: malloc 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that takes an int and converts it to a null-terminated string. 8 | The function returns the result in a char array that you must allocate. 9 | 10 | Your function must be declared as follows: 11 | 12 | char *ft_itoa(int nbr); 13 | ``` 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/ft_itoa/ft_itoa.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *ft_itoa(int nbr) 5 | { 6 | if(nbr == -2147483648) 7 | return("-2147483648\0"); 8 | int n = nbr; 9 | int len = 0; 10 | if (nbr <= 0) 11 | { 12 | len++; 13 | } 14 | while (n) 15 | { 16 | n /= 10; 17 | len++; 18 | } 19 | char *result = (char *)malloc(sizeof(char) * (len + 1)); 20 | if (result == NULL) 21 | return NULL; 22 | result[len] = '\0'; 23 | if (nbr == 0) 24 | { 25 | result[0] = '0'; 26 | return(result); 27 | } 28 | if (nbr < 0) 29 | { 30 | result[0] = '-'; 31 | nbr = -nbr; 32 | } 33 | while (nbr) 34 | { 35 | result[--len] = nbr % 10 + '0'; 36 | nbr /= 10; 37 | } 38 | return result; 39 | } -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/ft_list_foreach/ft_list.h: -------------------------------------------------------------------------------- 1 | typedef struct s_list 2 | { 3 | struct s_list *next; 4 | void *data; 5 | } t_list; -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/ft_list_foreach/ft_list_foreach.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ft_list.h" 3 | 4 | void ft_list_foreach(t_list *begin_list, void (*f)(void *)) 5 | { 6 | t_list *list_ptr; 7 | 8 | list_ptr = begin_list; 9 | while (list_ptr) 10 | { 11 | (*f)(list_ptr->data); 12 | list_ptr = list_ptr->next; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/ft_split/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : ft_split 3 | Expected files : ft_split.c 4 | Allowed functions: malloc 5 | -------------------------------------------------------------------------------- 6 | 7 | Write a function that takes a string, splits it into words, and returns them as 8 | a NULL-terminated array of strings. 9 | 10 | A "word" is defined as a part of a string delimited either by spaces/tabs/new 11 | lines, or by the start/end of the string. 12 | 13 | Your function must be declared as follows: 14 | 15 | char **ft_split(char *str); 16 | ``` 17 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/rev_wstr/rev_wstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int start; 6 | int end; 7 | int i = 0; 8 | 9 | if(argc == 2) 10 | { 11 | while(argv[1][i] != '\0') 12 | i++; 13 | while(i >= 0) 14 | { 15 | while( argv[1][i] == '\0' || argv[1][i] == ' ' || argv[1][i] == '\t') 16 | i--; 17 | end = i; 18 | while(argv[1][i] && argv[1][i] != ' ' && argv[1][i] != '\t') 19 | i--; 20 | start = i + 1; 21 | int flag; 22 | flag = start; 23 | while(start <= end) 24 | { 25 | write (1, &argv[1][start],1); 26 | start++; 27 | } 28 | if (flag !=0) 29 | { 30 | write(1, " ", 1); 31 | } 32 | } 33 | } 34 | write(1, "\n", 1); 35 | } 36 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/sort_int_tab/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Assignment name : sort_int_tab 3 | Expected files : sort_int_tab.c 4 | Allowed functions: 5 | -------------------------------------------------------------------------------- 6 | 7 | Write the following function: 8 | 9 | void sort_int_tab(int *tab, unsigned int size); 10 | 11 | It must sort (in-place) the 'tab' int array, that contains exactly 'size' 12 | members, in ascending order. 13 | 14 | Doubles must be preserved. 15 | 16 | Input is always coherent. 17 | ``` 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/sort_int_tab/sort_int_tab.c: -------------------------------------------------------------------------------- 1 | void sort_int_tab(int *tab, unsigned int size) 2 | { 3 | unsigned int i = 0; 4 | int temp; 5 | 6 | while (i < (size - 1)) 7 | { 8 | if (tab[i] > tab[i + 1]) 9 | { 10 | temp = tab[i]; 11 | tab[i] = tab[i+ 1]; 12 | tab[i + 1] = temp; 13 | i = 0; 14 | } 15 | else 16 | i++; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/sort_list/sort_list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "list.h" 3 | 4 | t_list *sort_list(t_list *lst, int (*cmp)(int, int)) 5 | { 6 | int swap; 7 | t_list *tmp; 8 | 9 | tmp = lst; 10 | while(lst->next != NULL) 11 | { 12 | if (((*cmp)(lst->data, lst->next->data)) == 0) 13 | { 14 | swap = lst->data; 15 | lst->data = lst->next->data; 16 | lst->next->data = swap; 17 | lst = tmp; 18 | } 19 | else 20 | lst = lst->next; 21 | } 22 | lst = tmp; 23 | return (lst); 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_2/exam_rank_02/level_3/sort_list/sort_list.list.h: -------------------------------------------------------------------------------- 1 | typedef struct s_list t_list; 2 | 3 | struct s_list 4 | { 5 | int data; 6 | t_list *next; 7 | }; 8 | -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/fract-ol/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/assets/fractal_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/fract-ol/assets/fractal_preview.png -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/assets/header_fractol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/fract-ol/assets/header_fractol.png -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 2.x.x | ✅ | 8 | | 1.0.x | ❌ | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | For security issues please refrain from opening an issue! 13 | Instead write an email to [main@w2wizard.dev](mailto:main@w2wizard.dev) 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/VERSION.md: -------------------------------------------------------------------------------- 1 | # Version 2 | 3 | ## Current Version: 2.2.0 4 | 5 | --- 6 | 7 | ## Latest: License GPL2.0 Build -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/docs/Functions.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Functions 7 | 8 | A list of all functions can be found here: [Functions](https://bit.ly/3aWZL7C) -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/docs/assets/XPM_Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/fract-ol/libs/libmlx/docs/assets/XPM_Demo.png -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/docs/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/fract-ol/libs/libmlx/docs/assets/logo.png -------------------------------------------------------------------------------- /42-cursus/circle_2/fract-ol/libs/libmlx/shaders/default.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPos; 4 | layout(location = 1) in vec2 aTexCoord; 5 | layout(location = 2) in int aTexIndex; 6 | 7 | out vec2 TexCoord; 8 | flat out int TexIndex; 9 | 10 | uniform mat4 ProjMatrix; 11 | 12 | void main() 13 | { 14 | gl_Position = ProjMatrix * vec4(aPos, 1.0); 15 | TexCoord = aTexCoord; 16 | TexIndex = aTexIndex; 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/pipex/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/assets/header_pipex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/pipex/assets/header_pipex.png -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_atoi.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_atoi(const char *str) 4 | { 5 | long atoi; 6 | int sign; 7 | 8 | atoi = 0; 9 | sign = 1; 10 | while ((*str >= 9 && *str <= 13) || *str == 32) 11 | str++; 12 | if (*str == 45 || *str == 43) 13 | { 14 | if (*str == 45) 15 | sign = -1; 16 | str++; 17 | } 18 | while (ft_isdigit(*str)) 19 | { 20 | atoi *= 10; 21 | atoi += *str - 48; 22 | str++; 23 | } 24 | return (atoi * sign); 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_bzero.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_bzero(void *str, size_t size) 4 | { 5 | size_t i; 6 | char *s; 7 | 8 | i = 0; 9 | s = (char *)str; 10 | while (i < size) 11 | s[i++] = 0; 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_calloc.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void *ft_calloc(size_t num, size_t size) 4 | { 5 | void *p; 6 | 7 | p = malloc(num * size); 8 | if (!p) 9 | return (NULL); 10 | ft_bzero(p, (num * size)); 11 | return (p); 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_isalnum.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_isalnum(int c) 4 | { 5 | return (ft_isalpha(c) || ft_isdigit(c)); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_isalpha.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_isalpha(int c) 4 | { 5 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_isascii.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_isascii(int c) 4 | { 5 | return (c >= 0 && c <= 127); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_isdigit.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_isdigit(int c) 4 | { 5 | return (c >= 48 && c <= 57); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_isprint.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_isprint(int c) 4 | { 5 | return (c >= 32 && c <= 126); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_itoa.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | size_t len_int(int n) 4 | { 5 | size_t len; 6 | 7 | len = 0; 8 | if (n <= 0) 9 | len++; 10 | while (n != 0) 11 | { 12 | len++; 13 | n /= 10; 14 | } 15 | return (len); 16 | } 17 | 18 | char *ft_itoa(int n) 19 | { 20 | char *str; 21 | size_t len; 22 | long long nl; 23 | 24 | nl = n; 25 | len = len_int(nl); 26 | str = (char *)malloc(sizeof(char) * (len + 1)); 27 | if (!str) 28 | return (NULL); 29 | if (nl < 0) 30 | { 31 | str[0] = '-'; 32 | nl *= -1; 33 | } 34 | str[len] = 0; 35 | str[--len] = (nl % 10) + '0'; 36 | nl /= 10; 37 | while (nl != 0 && len--) 38 | { 39 | str[len] = (nl % 10) + '0'; 40 | nl /= 10; 41 | } 42 | return (str); 43 | } 44 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstadd_back.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_lstadd_back(t_list **lst, t_list *new) 4 | { 5 | if (*lst) 6 | (ft_lstlast(*lst))->next = new; 7 | else 8 | *lst = new; 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstadd_front.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_lstadd_front(t_list **lst, t_list *new) 4 | { 5 | new->next = *lst; 6 | *lst = new; 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstclear.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_lstclear(t_list **lst, void (*del)(void *)) 4 | { 5 | t_list *aux; 6 | 7 | while (*lst) 8 | { 9 | aux = *lst; 10 | del((*lst)->content); 11 | *lst = (*lst)->next; 12 | free(aux); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstdelone.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_lstdelone(t_list *lst, void (*del)(void *)) 4 | { 5 | (*del)(lst->content); 6 | free(lst); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstiter.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_lstiter(t_list *lst, void (*f)(void *)) 4 | { 5 | while (lst) 6 | { 7 | f(lst->content); 8 | lst = lst->next; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstlast.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | t_list *ft_lstlast(t_list *lst) 4 | { 5 | if (!lst) 6 | return (NULL); 7 | while (lst->next) 8 | lst = lst->next; 9 | return (lst); 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstmap.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) 4 | { 5 | t_list *newlst; 6 | t_list *newel; 7 | 8 | if (!f || !del) 9 | return (NULL); 10 | newlst = NULL; 11 | while (lst) 12 | { 13 | newel = ft_lstnew(f(lst->content)); 14 | if (!newel) 15 | { 16 | ft_lstclear(&lst, del); 17 | return (NULL); 18 | } 19 | ft_lstadd_back(&newlst, newel); 20 | lst = lst->next; 21 | } 22 | return (newlst); 23 | } 24 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstnew.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | t_list *ft_lstnew(void *content) 4 | { 5 | t_list *new; 6 | 7 | new = malloc(sizeof(t_list)); 8 | if (!new) 9 | return (NULL); 10 | new->content = content; 11 | new->next = NULL; 12 | return (new); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_lstsize.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_lstsize(t_list *lst) 4 | { 5 | int size; 6 | 7 | size = 0; 8 | while (lst) 9 | { 10 | lst = lst->next; 11 | size++; 12 | } 13 | return (size); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memchr.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void *ft_memchr(const void *str, int c, size_t size) 4 | { 5 | size_t i; 6 | unsigned char *pstr; 7 | 8 | i = 0; 9 | pstr = (unsigned char *)str; 10 | while (size--) 11 | { 12 | if (pstr[i] == (unsigned char)c) 13 | return (&pstr[i]); 14 | i++; 15 | } 16 | return (NULL); 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memcmp.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_memcmp(const void *s1, const void *s2, size_t size) 4 | { 5 | unsigned char *str1; 6 | unsigned char *str2; 7 | size_t i; 8 | 9 | str1 = (unsigned char *)s1; 10 | str2 = (unsigned char *)s2; 11 | i = 0; 12 | while (size--) 13 | { 14 | if (str1[i] != str2[i]) 15 | return (str1[i] - str2[i]); 16 | i++; 17 | } 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memcpy.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void *ft_memcpy(void *dest, const void *src, size_t size) 4 | { 5 | char *d; 6 | char *s; 7 | 8 | d = (char *)dest; 9 | s = (char *)src; 10 | if (!dest && !src) 11 | return (NULL); 12 | while (size--) 13 | *d++ = *s++; 14 | return (dest); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memfree.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_memfree(void *ptr) 4 | { 5 | if (!ptr) 6 | return ; 7 | free(ptr); 8 | ptr = NULL; 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memfree_all.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_memfree_all(char **ptr) 4 | { 5 | int i; 6 | 7 | if (!ptr) 8 | return ; 9 | i = 0; 10 | while (ptr[i]) 11 | ft_memfree(ptr[i++]); 12 | free(ptr); 13 | ptr = NULL; 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memmove.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void *ft_memmove(void *dest, const void *src, size_t size) 4 | { 5 | char *d; 6 | char *s; 7 | 8 | d = (char *)dest; 9 | s = (char *)src; 10 | if (!dest && !src) 11 | return (NULL); 12 | if (d < s) 13 | ft_memcpy(d, s, size); 14 | else 15 | { 16 | while (size--) 17 | d[size] = s[size]; 18 | } 19 | return (d); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_memset.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void *ft_memset(void *str, int c, size_t size) 4 | { 5 | size_t i; 6 | char *pstr; 7 | 8 | i = 0; 9 | pstr = (char *)str; 10 | while (i < size) 11 | pstr[i++] = c; 12 | return (str); 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_printf.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_printf(const char *str, ...) 4 | { 5 | t_block b; 6 | 7 | ft_bzero(&b, sizeof(b)); 8 | va_start(b.ap, str); 9 | while (str[b.i]) 10 | { 11 | if (str[b.i] != '%') 12 | b.ret += write(1, &str[b.i++], 1); 13 | else 14 | { 15 | (b.i)++; 16 | reset_block_pf(&b); 17 | checkflags_pf(str, &b); 18 | checktypes_pf(str, &b); 19 | } 20 | } 21 | va_end(b.ap); 22 | reset_block_pf(&b); 23 | return (b.ret); 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_putchar_fd.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_putchar_fd(char c, int fd) 4 | { 5 | write(fd, &c, 1); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_putendl_fd.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_putendl_fd(char *s, int fd) 4 | { 5 | if (!s) 6 | return ; 7 | ft_putstr_fd(s, fd); 8 | ft_putchar_fd('\n', fd); 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_putnbr_fd(int n, int fd) 4 | { 5 | long nb; 6 | 7 | nb = n; 8 | if (nb < 0) 9 | { 10 | ft_putchar_fd('-', fd); 11 | nb *= -1; 12 | } 13 | if (nb >= 10) 14 | { 15 | ft_putnbr_fd(nb / 10, fd); 16 | ft_putnbr_fd(nb % 10, fd); 17 | } 18 | else 19 | ft_putchar_fd(nb + '0', fd); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_putstr_fd.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_putstr_fd(char *s, int fd) 4 | { 5 | if (!s) 6 | return ; 7 | write(fd, s, ft_strlen(s)); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strchr.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strchr(const char *str, int c) 4 | { 5 | while (*str != (char)c) 6 | { 7 | if (!(*str)) 8 | return (NULL); 9 | str++; 10 | } 11 | return ((char *)str); 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_strcmp(const char *s1, const char *s2) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | while (s1[i] && s2[i]) 9 | { 10 | if (s1[i] != s2[i]) 11 | return ((unsigned char)s1[i] - (unsigned char)s2[i]); 12 | i++; 13 | } 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strdup.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strdup(const char *str) 4 | { 5 | int len; 6 | char *copy; 7 | 8 | len = ft_strlen(str); 9 | copy = (char *)malloc(sizeof(char) * (len + 1)); 10 | if (!copy) 11 | return (NULL); 12 | while (len >= 0) 13 | { 14 | copy[len] = str[len]; 15 | len--; 16 | } 17 | return (copy); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_striteri.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_striteri(char *s, void (*f)(unsigned int, char *)) 4 | { 5 | size_t i; 6 | 7 | i = ft_strlen(s); 8 | while (i--) 9 | f(i, &s[i]); 10 | } 11 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strjoin.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strjoin(char const *s1, char const *s2) 4 | { 5 | char *str; 6 | size_t str_len; 7 | size_t i; 8 | 9 | str_len = (ft_strlen(s1) + ft_strlen(s2) + 1); 10 | str = (char *)malloc(sizeof(char) * str_len); 11 | if (!s1 || !s2 || !str) 12 | return (NULL); 13 | i = 0; 14 | while (*s1) 15 | str[i++] = *s1++; 16 | while (*s2) 17 | str[i++] = *s2++; 18 | str[i] = 0; 19 | return (str); 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strlcat.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | size_t ft_strlcat(char *dest, const char *src, size_t size) 4 | { 5 | size_t len_d; 6 | size_t len_s; 7 | size_t i; 8 | 9 | len_d = ft_strlen(dest); 10 | len_s = ft_strlen(src); 11 | if (len_d >= size) 12 | return (len_s + size); 13 | else if (len_d + 1 < size) 14 | { 15 | i = 0; 16 | while (src[i] && (len_d + i + 1 < size)) 17 | { 18 | dest[len_d + i] = src[i]; 19 | i++; 20 | } 21 | dest[len_d + i] = 0; 22 | } 23 | return (len_d + len_s); 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | size_t ft_strlcpy(char *dest, const char *src, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | if (size) 9 | { 10 | while (src[i] && i < (size - 1)) 11 | { 12 | dest[i] = src[i]; 13 | i++; 14 | } 15 | dest[i] = 0; 16 | } 17 | return (ft_strlen(src)); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strlen.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | size_t ft_strlen(const char *str) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | while (str[i]) 9 | i++; 10 | return (i); 11 | } 12 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strmapi.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) 4 | { 5 | size_t i; 6 | char *str; 7 | 8 | i = ft_strlen(s); 9 | str = (char *)malloc(sizeof(char) * (i + 1)); 10 | if (!str) 11 | return (NULL); 12 | str[i] = 0; 13 | while (i--) 14 | str[i] = f(i, s[i]); 15 | return (str); 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_strncmp(const char *s1, const char *s2, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = 0; 8 | while (size--) 9 | { 10 | if (s1[i] != s2[i] || s1[i] == 0 || s2[i] == 0) 11 | return ((unsigned char)s1[i] - (unsigned char)s2[i]); 12 | i++; 13 | } 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strnstr.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strnstr(const char *haystack, const char *needle, size_t size) 4 | { 5 | size_t i; 6 | 7 | i = ft_strlen(needle); 8 | if (!(*needle)) 9 | return ((char *)haystack); 10 | while (*haystack && size-- >= i) 11 | { 12 | if (*haystack == *needle && ft_strncmp(haystack, needle, i) == 0) 13 | return ((char *)haystack); 14 | haystack++; 15 | } 16 | return (NULL); 17 | } 18 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strrchr.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strrchr(const char *str, int c) 4 | { 5 | size_t i; 6 | 7 | i = ft_strlen(str) + 1; 8 | while (i--) 9 | { 10 | if (str[i] == (char)c) 11 | return ((char *)&str[i]); 12 | } 13 | return (NULL); 14 | } 15 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_strtrim.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_strtrim(char const *s1, char const *set) 4 | { 5 | size_t i; 6 | 7 | if (!s1 || !set) 8 | return (NULL); 9 | while (ft_strchr(set, *s1) && *s1) 10 | s1++; 11 | i = ft_strlen(s1); 12 | while (ft_strchr(set, s1[i]) && i != 0) 13 | i--; 14 | return (ft_substr(s1, 0, i + 1)); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_substr.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | char *ft_substr(char const *s, unsigned int start, size_t len) 4 | { 5 | char *substr; 6 | 7 | if (!s) 8 | return (NULL); 9 | if (ft_strlen(s) < start) 10 | return (ft_strdup("")); 11 | if (len > ft_strlen(s + start)) 12 | len = ft_strlen(s + start); 13 | substr = malloc(sizeof(char) * (len + 1)); 14 | if (!substr) 15 | return (NULL); 16 | ft_strlcpy(substr, s + start, len + 1); 17 | return (substr); 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_tolower.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_tolower(int c) 4 | { 5 | if (c >= 'A' && c <= 'Z') 6 | c += 32; 7 | return (c); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_toupper.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | int ft_toupper(int c) 4 | { 5 | if (c >= 'a' && c <= 'z') 6 | c -= 32; 7 | return (c); 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_2/pipex/libft/src/ft_toupper_str.c: -------------------------------------------------------------------------------- 1 | #include "../inc/libft.h" 2 | 3 | void ft_toupper_str(char *str) 4 | { 5 | int len; 6 | int i; 7 | 8 | i = 0; 9 | len = ft_strlen(str); 10 | while (len--) 11 | { 12 | str[i] = ft_toupper(str[i]); 13 | i++; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_2/push_swap/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/push_swap/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_2/push_swap/assets/header_push_swap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_2/push_swap/assets/header_push_swap.png -------------------------------------------------------------------------------- /42-cursus/circle_3/exam_rank_03/assets/exam_rank_03_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/exam_rank_03/assets/exam_rank_03_header.png -------------------------------------------------------------------------------- /42-cursus/circle_3/exam_rank_03/assets/grademe_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/exam_rank_03/assets/grademe_01.png -------------------------------------------------------------------------------- /42-cursus/circle_3/exam_rank_03/get_next_line.c: -------------------------------------------------------------------------------- 1 | #include // For read 2 | #include // For malloc && free 3 | 4 | // #define BUFFER_SIZE 8192 5 | 6 | char *get_next_line(int fd) 7 | { 8 | int index; 9 | int bytes; 10 | char *buffer; 11 | char character; 12 | 13 | if ((fd < 0) || (BUFFER_SIZE <= 0)) 14 | return (NULL); 15 | index = 0; 16 | bytes = read(fd, &character, 1); 17 | buffer = (char *)malloc(sizeof(char) * (BUFFER_SIZE + 1)); 18 | while (bytes > 0) 19 | { 20 | buffer[index++] = character; 21 | if (character == '\n') 22 | break ; 23 | bytes = read(fd, &character, 1); 24 | } 25 | if ((bytes <= 0) && (index == 0)) 26 | return (free(buffer), NULL); 27 | buffer[index] = '\0'; 28 | return (buffer); 29 | } 30 | -------------------------------------------------------------------------------- /42-cursus/circle_3/philosophers/assets/es.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/philosophers/assets/es.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_3/philosophers/assets/header_philo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/philosophers/assets/header_philo.png -------------------------------------------------------------------------------- /42-cursus/circle_3/philosophers/assets/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/philosophers/assets/img1.png -------------------------------------------------------------------------------- /42-cursus/circle_3/philosophers/assets/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_3/philosophers/assets/img2.png -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_00/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/CPP_Module_0-4/Module_00/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_00/ex00/megaphone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | if (argc == 1) 6 | std::cout << "* LOUD AND UNBEARABLE FEEDBACK NOISE *"; 7 | for (int i = 1; argv[i]; i++) 8 | { 9 | for (int j = 0; argv[i][j]; j++) 10 | std::cout << (char)toupper(argv[i][j]); 11 | std::cout << " "; 12 | } 13 | std::cout << std::endl; 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_00/ex01/include/Contact.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CONTACT_HPP 2 | #define CONTACT_HPP 3 | 4 | #include 5 | #include 6 | 7 | class Contact 8 | { 9 | private: 10 | std::string _firstName; 11 | std::string _lastName; 12 | std::string _nickName; 13 | std::string _phoneNumber; 14 | std::string _darkestSecret; 15 | int _index; 16 | 17 | std::string _getInput(std::string data) const; 18 | std::string _printLen(std::string str) const; 19 | 20 | public: 21 | Contact(); 22 | ~Contact(); 23 | void init(int i); 24 | void show(int i); 25 | void display(); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_00/ex01/include/PhoneBook.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PHONEBOOK_HPP 2 | #define PHONEBOOK_HPP 3 | 4 | #include "../include/Contact.hpp" 5 | #include 6 | 7 | class PhoneBook 8 | { 9 | private: 10 | Contact _contacts[2]; 11 | int _currSize; 12 | 13 | int _readInput() const; 14 | 15 | public: 16 | PhoneBook(); 17 | ~PhoneBook(); 18 | void welcome(void) const; 19 | void add(void); 20 | void search(void); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_00/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "./include/PhoneBook.hpp" 2 | 3 | int main(int argc, char **argv) 4 | { 5 | if (argc > 1 && argv) 6 | return 1; 7 | 8 | PhoneBook book; 9 | std::string input = ""; 10 | 11 | book.welcome(); 12 | while (input.compare("EXIT")) 13 | { 14 | std::cin.clear(); 15 | std::cout << "> "; 16 | std::getline(std::cin, input); 17 | if (!input.compare("ADD")) 18 | book.add(); 19 | else if (!input.compare("SEARCH")) 20 | book.search(); 21 | } 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/CPP_Module_0-4/Module_01/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex00/Zombie.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | Zombie::Zombie(std::string name) 4 | { 5 | this->_name = name; 6 | } 7 | 8 | Zombie::~Zombie(void) 9 | { 10 | std::cout << "Zombie " << this->_name << " has been destroyed." << std::endl; 11 | } 12 | 13 | void Zombie::announce(void) 14 | { 15 | std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl; 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex00/Zombie.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ZOMBIE_HPP 2 | #define ZOMBIE_HPP 3 | 4 | #include 5 | 6 | class Zombie 7 | { 8 | private: 9 | std::string _name; 10 | 11 | public: 12 | Zombie(std::string name); 13 | ~Zombie(); 14 | 15 | void announce(void); 16 | }; 17 | 18 | Zombie *newZombie(std::string name); 19 | void randomChump(std::string name); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex00/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | int main(void) 4 | { 5 | std::string name; 6 | 7 | std::cout << "Creating zombie on the stack." << std::endl; 8 | std::cout << "Zombie name: " << std::flush; 9 | std::cin >> name; 10 | 11 | Zombie zombie1(name); 12 | 13 | std::cout << "Creating zombie on the heap." << std::endl; 14 | std::cout << "Zombie name: " << std::flush; 15 | std::cin >> name; 16 | 17 | Zombie *zombie2 = newZombie(name); 18 | zombie2->announce(); 19 | delete zombie2; 20 | 21 | std::cout << "Calling randonChump()." << std::endl; 22 | randomChump("randi"); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex00/newZombie.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | Zombie *newZombie(std::string name) 4 | { 5 | return new Zombie(name); 6 | } 7 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex00/randomChump.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | void randomChump(std::string name) 4 | { 5 | Zombie zombie(name); 6 | zombie.announce(); 7 | } 8 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex01/Zombie.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | Zombie::Zombie() 4 | { 5 | } 6 | 7 | Zombie::~Zombie() 8 | { 9 | } 10 | 11 | void Zombie::announce(void) 12 | { 13 | std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl; 14 | } 15 | 16 | void Zombie::setName(std::string name) 17 | { 18 | this->_name = name; 19 | } 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex01/Zombie.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ZOMBIE_HPP 2 | #define ZOMBIE_HPP 3 | 4 | #include 5 | 6 | class Zombie 7 | { 8 | private: 9 | std::string _name; 10 | 11 | public: 12 | Zombie(); 13 | ~Zombie(); 14 | void announce(void); 15 | void setName(std::string name); 16 | }; 17 | 18 | Zombie *zombieHorde(int N, std::string name); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | int main(void) 4 | { 5 | const int N = 2; 6 | Zombie *zombie = zombieHorde(N, "zombie"); 7 | 8 | for (int i = 0; i < N; i++) 9 | zombie[i].announce(); 10 | 11 | delete[] zombie; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex01/zombieHorde.cpp: -------------------------------------------------------------------------------- 1 | #include "Zombie.hpp" 2 | 3 | Zombie *zombieHorde(int N, std::string name) 4 | { 5 | Zombie *zombie = new Zombie[N]; 6 | for (int i = 0; i < N; i++) 7 | zombie[i].setName(name); 8 | return zombie; 9 | } 10 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex02/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | std::string str = "HI THIS IS BRAIN"; 6 | std::string *strPTR = &str; 7 | std::string &strREF = str; 8 | 9 | std::cout << "Address of str:\t\t" << &str << std::endl; 10 | std::cout << "Thru pointer value:\t" << strPTR << std::endl; 11 | std::cout << "Thru reference value:\t" << &strREF << std::endl; 12 | 13 | std::cout << std::endl; 14 | 15 | std::cout << "Value of str:\t\t\t" << str << std::endl; 16 | std::cout << "Thru pointer dereferencing:\t" << *strPTR << std::endl; 17 | std::cout << "Thru reference:\t\t\t" << strREF << std::endl; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/inc/HumanA.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HUMANA_HPP 2 | #define HUMANA_HPP 3 | 4 | #include "Weapon.hpp" 5 | 6 | class HumanA 7 | { 8 | private: 9 | std::string _name; 10 | Weapon &_weapon; 11 | 12 | public: 13 | HumanA(std::string name, Weapon &weapon); 14 | ~HumanA(); 15 | 16 | void attack(void) const; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/inc/HumanB.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HUMANB_HPP 2 | #define HUMANB_HPP 3 | 4 | #include "Weapon.hpp" 5 | 6 | class HumanB 7 | { 8 | private: 9 | std::string _name; 10 | Weapon *_weapon; 11 | 12 | public: 13 | HumanB(std::string name); 14 | ~HumanB(); 15 | 16 | void setWeapon(Weapon &weapon); 17 | void attack(void) const; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/inc/Weapon.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WEAPON_HPP 2 | #define WEAPON_HPP 3 | 4 | #include 5 | 6 | class Weapon 7 | { 8 | private: 9 | std::string _type; 10 | 11 | public: 12 | Weapon(std::string type); 13 | ~Weapon(); 14 | 15 | const std::string &getType(void) const; 16 | void setType(std::string type); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/main.cpp: -------------------------------------------------------------------------------- 1 | #include "HumanA.hpp" 2 | #include "HumanB.hpp" 3 | 4 | int main(void) 5 | { 6 | { 7 | Weapon club = Weapon("crude spiked club"); 8 | HumanA bob("Bob", club); 9 | bob.attack(); 10 | club.setType("some other type of club"); 11 | bob.attack(); 12 | } 13 | { 14 | Weapon club = Weapon("crude spiked club"); 15 | HumanB jim("Jim"); 16 | jim.setWeapon(club); 17 | jim.attack(); 18 | club.setType("some other type of club"); 19 | jim.attack(); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/src/HumanA.cpp: -------------------------------------------------------------------------------- 1 | #include "HumanA.hpp" 2 | 3 | HumanA::HumanA(std::string name, Weapon &weapon) : _name(name), _weapon(weapon) {} 4 | 5 | HumanA::~HumanA() {} 6 | 7 | void HumanA::attack(void) const 8 | { 9 | if (this->_weapon.getType().empty()) 10 | { 11 | std::cout << this->_name 12 | << " doesn't have a weapon to attack." 13 | << this->_weapon.getType() << std::endl; 14 | } 15 | else 16 | { 17 | std::cout << this->_name 18 | << " attacks with their " 19 | << this->_weapon.getType() << std::endl; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/src/HumanB.cpp: -------------------------------------------------------------------------------- 1 | #include "HumanB.hpp" 2 | 3 | HumanB::HumanB(std::string name) : _name(name) {} 4 | 5 | HumanB::~HumanB() {} 6 | 7 | void HumanB::setWeapon(Weapon &weapon) 8 | { 9 | this->_weapon = &weapon; 10 | } 11 | 12 | void HumanB::attack(void) const 13 | { 14 | if (!this->_weapon && this->_weapon->getType().empty()) 15 | { 16 | std::cout << this->_name 17 | << " doesn't have a weapon to attack." 18 | << this->_weapon->getType() << std::endl; 19 | } 20 | else 21 | { 22 | std::cout << this->_name 23 | << " attacks with their " 24 | << this->_weapon->getType() << std::endl; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex03/src/Weapon.cpp: -------------------------------------------------------------------------------- 1 | #include "Weapon.hpp" 2 | 3 | Weapon::Weapon(std::string type) 4 | { 5 | this->setType(type); 6 | } 7 | 8 | Weapon::~Weapon() 9 | { 10 | } 11 | 12 | const std::string &Weapon::getType(void) const 13 | { 14 | return this->_type; 15 | } 16 | 17 | void Weapon::setType(std::string type) 18 | { 19 | this->_type = type; 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex05/Harl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HARL_HPP 2 | #define HARL_HPP 3 | 4 | #include 5 | 6 | class Harl 7 | { 8 | private: 9 | void debug(void); 10 | void info(void); 11 | void warning(void); 12 | void error(void); 13 | 14 | public: 15 | Harl(); 16 | ~Harl(); 17 | 18 | void complain(std::string level); 19 | }; 20 | 21 | typedef void (Harl::*t_func)(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex05/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Harl.hpp" 2 | 3 | int main(void) 4 | { 5 | std::string input; 6 | Harl harl; 7 | 8 | do 9 | { 10 | std::cout << "Enter a level: "; 11 | std::cin >> input; 12 | harl.complain(input); 13 | } while (input.compare("exit")); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex06/Harl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HARL_HPP 2 | #define HARL_HPP 3 | 4 | #include 5 | 6 | class Harl 7 | { 8 | private: 9 | void debug(void); 10 | void info(void); 11 | void warning(void); 12 | void error(void); 13 | 14 | public: 15 | Harl(); 16 | ~Harl(); 17 | 18 | void complain(std::string level); 19 | }; 20 | 21 | typedef void (Harl::*t_func)(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_01/ex06/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Harl.hpp" 2 | 3 | int main(int ac, char **av) 4 | { 5 | if (ac != 2) 6 | return (std::cerr << "Usage: ./harlFilter \"level\"\n", 1); 7 | 8 | Harl harl; 9 | harl.complain(av[1]); 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/CPP_Module_0-4/Module_02/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/ex00/Fixed.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FIXED_HPP 2 | #define FIXED_HPP 3 | 4 | #include 5 | 6 | class Fixed 7 | { 8 | private: 9 | int _fixedPointValue; 10 | static const int _fractionalBits = 8; 11 | 12 | public: 13 | Fixed(); 14 | Fixed(const Fixed &to_copy); 15 | Fixed &operator=(const Fixed &to_copy); 16 | ~Fixed(); 17 | 18 | int getRawBits(void) const; 19 | void setRawBits(int const raw); 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/ex00/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Fixed.hpp" 2 | 3 | int main(void) 4 | { 5 | Fixed a; 6 | Fixed b(a); 7 | Fixed c; 8 | 9 | c = b; 10 | 11 | std::cout << a.getRawBits() << std::endl; 12 | std::cout << b.getRawBits() << std::endl; 13 | std::cout << c.getRawBits() << std::endl; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/ex01/Fixed.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FIXED_HPP 2 | #define FIXED_HPP 3 | 4 | #include 5 | 6 | class Fixed 7 | { 8 | private: 9 | int _fixedPointValue; 10 | static const int _bits = 8; 11 | 12 | public: 13 | Fixed(void); 14 | Fixed(const int n); 15 | Fixed(const float n); 16 | Fixed(const Fixed &to_copy); 17 | Fixed &operator=(const Fixed &to_copy); 18 | ~Fixed(); 19 | 20 | int getRawBits(void) const; 21 | void setRawBits(int const raw); 22 | 23 | float toFloat(void) const; 24 | int toInt(void) const; 25 | }; 26 | 27 | std::ostream &operator<<(std::ostream &stream, Fixed const &i); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Fixed.hpp" 2 | 3 | int main(void) 4 | { 5 | Fixed a; 6 | Fixed const b(10); 7 | Fixed const c(42.42f); 8 | Fixed const d(b); 9 | 10 | a = Fixed(1234.4321f); 11 | 12 | std::cout << "a is " << a << std::endl; 13 | std::cout << "b is " << b << std::endl; 14 | std::cout << "c is " << c << std::endl; 15 | std::cout << "d is " << d << std::endl; 16 | 17 | std::cout << "a is " << a.toInt() << " as integer" << std::endl; 18 | std::cout << "b is " << b.toInt() << " as integer" << std::endl; 19 | std::cout << "c is " << c.toInt() << " as integer" << std::endl; 20 | std::cout << "d is " << d.toInt() << " as integer" << std::endl; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_02/ex02/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Fixed.hpp" 2 | 3 | int main(void) 4 | { 5 | Fixed a; 6 | Fixed const b(Fixed(5.05f) * Fixed(2)); 7 | 8 | std::cout << a << std::endl; 9 | std::cout << ++a << std::endl; 10 | std::cout << a << std::endl; 11 | std::cout << a++ << std::endl; 12 | std::cout << a << std::endl; 13 | std::cout << b << std::endl; 14 | 15 | std::cout << Fixed::max(a, b) << std::endl; 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/CPP_Module_0-4/Module_03/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex00/ClapTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLAPTRAP_HPP 2 | #define CLAPTRAP_HPP 3 | 4 | #include 5 | 6 | class ClapTrap 7 | { 8 | private: 9 | std::string _name; 10 | unsigned int _hitPoints; 11 | unsigned int _energyPoints; 12 | unsigned int _attackDamage; 13 | 14 | public: 15 | ClapTrap(std::string name); 16 | ClapTrap(const ClapTrap &to_copy); 17 | ClapTrap &operator=(const ClapTrap &original); 18 | ~ClapTrap(); 19 | 20 | void attack(const std::string &target); 21 | void takeDamage(unsigned int amount); 22 | void beRepaired(unsigned int amount); 23 | 24 | void setAttack(const unsigned int damage); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex00/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ClapTrap.hpp" 2 | 3 | int main(void) 4 | { 5 | ClapTrap JackSparrow("JackSparrow"); 6 | ClapTrap DavyJones("DavyJones"); 7 | std::cout << std::endl; 8 | 9 | JackSparrow.setAttack(5); 10 | JackSparrow.attack("DavyJones"); 11 | DavyJones.takeDamage(5); 12 | std::cout << std::endl; 13 | 14 | JackSparrow.setAttack(2); 15 | JackSparrow.attack("DavyJones"); 16 | DavyJones.takeDamage(2); 17 | std::cout << std::endl; 18 | 19 | DavyJones.beRepaired(7); 20 | std::cout << std::endl; 21 | 22 | JackSparrow.setAttack(10); 23 | JackSparrow.attack("DavyJones"); 24 | DavyJones.takeDamage(10); 25 | std::cout << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex01/inc/ClapTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLAPTRAP_HPP 2 | #define CLAPTRAP_HPP 3 | 4 | #include 5 | 6 | class ClapTrap 7 | { 8 | protected: 9 | std::string _name; 10 | unsigned int _hitPoints; 11 | unsigned int _energyPoints; 12 | unsigned int _attackDamage; 13 | 14 | public: 15 | ClapTrap(std::string name); 16 | ClapTrap(const ClapTrap &to_copy); 17 | ClapTrap &operator=(const ClapTrap &original); 18 | ~ClapTrap(); 19 | 20 | void attack(const std::string &target); 21 | void takeDamage(unsigned int amount); 22 | void beRepaired(unsigned int amount); 23 | 24 | void setAttack(const unsigned int damage); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex01/inc/ScavTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCAVTRAP_HPP 2 | #define SCAVTRAP_HPP 3 | 4 | #include "ClapTrap.hpp" 5 | 6 | class ScavTrap : public ClapTrap 7 | { 8 | private: 9 | ScavTrap(); 10 | 11 | public: 12 | ScavTrap(std::string name); 13 | ~ScavTrap(); 14 | 15 | void attack(const std::string &target); 16 | void guardGate(); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "inc/ScavTrap.hpp" 2 | 3 | int main(void) 4 | { 5 | ScavTrap JackSparrow("JackSparrow"); 6 | ScavTrap DavyJones("DavyJones"); 7 | std::cout << std::endl; 8 | 9 | JackSparrow.setAttack(7); 10 | JackSparrow.attack("DavyJones"); 11 | DavyJones.takeDamage(7); 12 | std::cout << std::endl; 13 | 14 | DavyJones.beRepaired(7); 15 | std::cout << std::endl; 16 | 17 | JackSparrow.setAttack(10); 18 | JackSparrow.attack("DavyJones"); 19 | DavyJones.takeDamage(10); 20 | std::cout << std::endl; 21 | 22 | JackSparrow.guardGate(); 23 | DavyJones.guardGate(); 24 | std::cout << std::endl; 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex02/inc/ClapTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLAPTRAP_HPP 2 | #define CLAPTRAP_HPP 3 | 4 | #include 5 | 6 | class ClapTrap 7 | { 8 | protected: 9 | std::string _name; 10 | unsigned int _hitPoints; 11 | unsigned int _energyPoints; 12 | unsigned int _attackDamage; 13 | 14 | public: 15 | ClapTrap(std::string name); 16 | ClapTrap(const ClapTrap &to_copy); 17 | ClapTrap &operator=(const ClapTrap &original); 18 | ~ClapTrap(); 19 | 20 | void attack(const std::string &target); 21 | void takeDamage(unsigned int amount); 22 | void beRepaired(unsigned int amount); 23 | 24 | void setAttack(const unsigned int damage); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex02/inc/FragTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FRAGTRAP_HPP 2 | #define FRAGTRAP_HPP 3 | 4 | #include "ClapTrap.hpp" 5 | 6 | class FragTrap : public ClapTrap 7 | { 8 | private: 9 | FragTrap(); 10 | 11 | public: 12 | FragTrap(std::string name); 13 | ~FragTrap(); 14 | 15 | void highFive(void); 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex02/inc/ScavTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCAVTRAP_HPP 2 | #define SCAVTRAP_HPP 3 | 4 | #include "ClapTrap.hpp" 5 | 6 | class ScavTrap : public ClapTrap 7 | { 8 | private: 9 | ScavTrap(); 10 | 11 | public: 12 | ScavTrap(std::string name); 13 | ~ScavTrap(); 14 | 15 | void attack(const std::string &target); 16 | void guardGate(); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex02/main.cpp: -------------------------------------------------------------------------------- 1 | #include "inc/FragTrap.hpp" 2 | 3 | int main(void) 4 | { 5 | FragTrap JackSparrow("JackSparrow"); 6 | FragTrap DavyJones("DavyJones"); 7 | std::cout << std::endl; 8 | 9 | JackSparrow.setAttack(7); 10 | JackSparrow.attack("DavyJones"); 11 | DavyJones.takeDamage(7); 12 | std::cout << std::endl; 13 | 14 | DavyJones.beRepaired(7); 15 | std::cout << std::endl; 16 | 17 | JackSparrow.setAttack(10); 18 | JackSparrow.attack("DavyJones"); 19 | DavyJones.takeDamage(10); 20 | std::cout << std::endl; 21 | 22 | DavyJones.highFive(); 23 | std::cout << std::endl; 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex03/inc/ClapTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLAPTRAP_HPP 2 | #define CLAPTRAP_HPP 3 | 4 | #include 5 | 6 | class ClapTrap 7 | { 8 | protected: 9 | std::string _name; 10 | unsigned int _hitPoints; 11 | unsigned int _energyPoints; 12 | unsigned int _attackDamage; 13 | 14 | public: 15 | ClapTrap(std::string name); 16 | ClapTrap(const ClapTrap &to_copy); 17 | ClapTrap &operator=(const ClapTrap &original); 18 | ~ClapTrap(); 19 | 20 | void attack(const std::string &target); 21 | void takeDamage(unsigned int amount); 22 | void beRepaired(unsigned int amount); 23 | 24 | void setAttack(const unsigned int damage); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex03/inc/DiamondTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DIAMONDTRAP_HPP 2 | #define DIAMONDTRAP_HPP 3 | 4 | #include "FragTrap.hpp" 5 | #include "ScavTrap.hpp" 6 | 7 | class DiamondTrap : public FragTrap, public ScavTrap 8 | { 9 | private: 10 | std::string _name; 11 | 12 | public: 13 | DiamondTrap(std::string name); 14 | ~DiamondTrap(); 15 | 16 | using ScavTrap::attack; 17 | void whoAmI(void); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex03/inc/FragTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FRAGTRAP_HPP 2 | #define FRAGTRAP_HPP 3 | 4 | #include "ClapTrap.hpp" 5 | 6 | class FragTrap : virtual public ClapTrap 7 | { 8 | private: 9 | FragTrap(); 10 | 11 | public: 12 | FragTrap(std::string name); 13 | ~FragTrap(); 14 | 15 | void highFive(void); 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex03/inc/ScavTrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCAVTRAP_HPP 2 | #define SCAVTRAP_HPP 3 | 4 | #include "ClapTrap.hpp" 5 | 6 | class ScavTrap : virtual public ClapTrap 7 | { 8 | private: 9 | ScavTrap(); 10 | 11 | public: 12 | ScavTrap(std::string name); 13 | ~ScavTrap(); 14 | 15 | void attack(const std::string &target); 16 | void guardGate(); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_03/ex03/main.cpp: -------------------------------------------------------------------------------- 1 | #include "inc/DiamondTrap.hpp" 2 | 3 | int main(void) 4 | { 5 | DiamondTrap JackSparrow("JackSparrow"); 6 | DiamondTrap DavyJones("DavyJones"); 7 | std::cout << std::endl; 8 | 9 | JackSparrow.whoAmI(); 10 | DavyJones.whoAmI(); 11 | 12 | // JackSparrow.setAttack(10); 13 | // JackSparrow.attack("DavyJones"); 14 | // DavyJones.takeDamage(10); 15 | // std::cout << std::endl; 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/CPP_Module_0-4/Module_04/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex00/inc/Animal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ANIMAL_HPP 2 | #define ANIMAL_HPP 3 | 4 | #include 5 | #include 6 | 7 | class Animal 8 | { 9 | protected: 10 | std::string _type; 11 | 12 | public: 13 | Animal(void); 14 | Animal(std::string type); 15 | Animal(const Animal &to_copy); 16 | Animal &operator=(const Animal &original); 17 | virtual ~Animal(void); 18 | 19 | std::string getType(void) const; 20 | virtual void makeSound(void) const; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex00/inc/Cat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAT_HPP 2 | #define CAT_HPP 3 | 4 | #include "Animal.hpp" 5 | 6 | class Cat : public Animal 7 | { 8 | public: 9 | Cat(void); 10 | Cat(const Cat &to_copy); 11 | Cat &operator=(const Cat &original); 12 | virtual ~Cat(); 13 | 14 | void makeSound(void) const; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex00/inc/Dog.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DOG_HPP 2 | #define DOG_HPP 3 | 4 | #include "Animal.hpp" 5 | 6 | class Dog : public Animal 7 | { 8 | public: 9 | Dog(void); 10 | Dog(const Dog &to_copy); 11 | Dog &operator=(const Dog &original); 12 | virtual ~Dog(); 13 | 14 | void makeSound(void) const; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex00/inc/WrongAnimal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGANIMAL_HPP 2 | #define WRONGANIMAL_HPP 3 | 4 | #include 5 | 6 | class WrongAnimal 7 | { 8 | protected: 9 | std::string _type; 10 | 11 | public: 12 | WrongAnimal(); 13 | WrongAnimal(std::string type); 14 | WrongAnimal(const WrongAnimal &to_copy); 15 | WrongAnimal &operator=(const WrongAnimal &original); 16 | virtual ~WrongAnimal(); 17 | 18 | std::string getType() const; 19 | virtual void makeSound() const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex00/inc/WrongCat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGCAT_HPP 2 | #define WRONGCAT_HPP 3 | 4 | #include "WrongAnimal.hpp" 5 | 6 | class WrongCat : public WrongAnimal 7 | { 8 | public: 9 | WrongCat(); 10 | WrongCat(const WrongCat ©); 11 | WrongCat &operator=(const WrongCat &original); 12 | virtual ~WrongCat(); 13 | 14 | void makeSound() const; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/Animal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ANIMAL_HPP 2 | #define ANIMAL_HPP 3 | 4 | #include 5 | #include 6 | 7 | class Animal 8 | { 9 | protected: 10 | std::string _type; 11 | 12 | public: 13 | Animal(void); 14 | Animal(std::string type); 15 | Animal(const Animal &to_copy); 16 | Animal &operator=(const Animal &original); 17 | virtual ~Animal(void); 18 | 19 | std::string getType(void) const; 20 | virtual void makeSound(void) const; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/Brain.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BRAIN_HPP 2 | #define BRAIN_HPP 3 | 4 | #include 5 | 6 | class Brain 7 | { 8 | private: 9 | std::string _ideas[100]; 10 | 11 | public: 12 | Brain(); 13 | Brain(const Brain ©); 14 | Brain &operator=(const Brain &original); 15 | virtual ~Brain(); 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/Cat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAT_HPP 2 | #define CAT_HPP 3 | 4 | #include "Animal.hpp" 5 | #include "Brain.hpp" 6 | 7 | class Cat : public Animal 8 | { 9 | private: 10 | Brain *_brain; 11 | public: 12 | Cat(void); 13 | Cat(const Cat &to_copy); 14 | Cat &operator=(const Cat &original); 15 | virtual ~Cat(); 16 | 17 | void makeSound(void) const; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/Dog.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DOG_HPP 2 | #define DOG_HPP 3 | 4 | #include "Animal.hpp" 5 | #include "Brain.hpp" 6 | 7 | class Dog : public Animal 8 | { 9 | private: 10 | Brain *_brain; 11 | 12 | public: 13 | Dog(void); 14 | Dog(const Dog &to_copy); 15 | Dog &operator=(const Dog &original); 16 | virtual ~Dog(); 17 | 18 | void makeSound(void) const; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/WrongAnimal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGANIMAL_HPP 2 | #define WRONGANIMAL_HPP 3 | 4 | #include 5 | 6 | class WrongAnimal 7 | { 8 | protected: 9 | std::string _type; 10 | 11 | public: 12 | WrongAnimal(); 13 | WrongAnimal(std::string type); 14 | WrongAnimal(const WrongAnimal &to_copy); 15 | WrongAnimal &operator=(const WrongAnimal &original); 16 | virtual ~WrongAnimal(); 17 | 18 | std::string getType() const; 19 | virtual void makeSound() const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/inc/WrongCat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGCAT_HPP 2 | #define WRONGCAT_HPP 3 | 4 | #include "WrongAnimal.hpp" 5 | 6 | class WrongCat : public WrongAnimal 7 | { 8 | public: 9 | WrongCat(); 10 | WrongCat(const WrongCat ©); 11 | WrongCat &operator=(const WrongCat &original); 12 | virtual ~WrongCat(); 13 | 14 | void makeSound() const; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex01/src/Brain.cpp: -------------------------------------------------------------------------------- 1 | #include "Brain.hpp" 2 | 3 | Brain::Brain() 4 | { 5 | std::cout << "Brain constructor called" << std::endl; 6 | } 7 | 8 | Brain::Brain(const Brain ©) 9 | { 10 | std::cout << "Brain copy constructor called" << std::endl; 11 | *this = copy; 12 | } 13 | 14 | Brain &Brain::operator=(const Brain &original) 15 | { 16 | if (this != &original) 17 | for (int i = 0; i < 100; i++) 18 | this->_ideas[i] = original._ideas[i]; 19 | return *this; 20 | } 21 | 22 | Brain::~Brain() 23 | { 24 | std::cout << "Brain destructor called" << std::endl; 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/AAnimal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef AAnimal_HPP 2 | #define AAnimal_HPP 3 | 4 | #include 5 | #include 6 | 7 | class AAnimal 8 | { 9 | protected: 10 | std::string _type; 11 | 12 | public: 13 | AAnimal(void); 14 | AAnimal(std::string type); 15 | AAnimal(const AAnimal &to_copy); 16 | AAnimal &operator=(const AAnimal &original); 17 | virtual ~AAnimal(void); 18 | 19 | std::string getType(void) const; 20 | virtual void makeSound(void) const = 0; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/Brain.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BRAIN_HPP 2 | #define BRAIN_HPP 3 | 4 | #include 5 | 6 | class Brain 7 | { 8 | private: 9 | std::string _ideas[100]; 10 | 11 | public: 12 | Brain(); 13 | Brain(const Brain ©); 14 | Brain &operator=(const Brain &original); 15 | virtual ~Brain(); 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/Cat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CAT_HPP 2 | #define CAT_HPP 3 | 4 | #include "AAnimal.hpp" 5 | #include "Brain.hpp" 6 | 7 | class Cat : public AAnimal 8 | { 9 | private: 10 | Brain *_brain; 11 | public: 12 | Cat(void); 13 | Cat(const Cat &to_copy); 14 | Cat &operator=(const Cat &original); 15 | virtual ~Cat(); 16 | 17 | void makeSound(void) const; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/Dog.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DOG_HPP 2 | #define DOG_HPP 3 | 4 | #include "AAnimal.hpp" 5 | #include "Brain.hpp" 6 | 7 | class Dog : public AAnimal 8 | { 9 | private: 10 | Brain *_brain; 11 | 12 | public: 13 | Dog(void); 14 | Dog(const Dog &to_copy); 15 | Dog &operator=(const Dog &original); 16 | virtual ~Dog(); 17 | 18 | void makeSound(void) const; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/WrongAnimal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGANIMAL_HPP 2 | #define WRONGANIMAL_HPP 3 | 4 | #include 5 | 6 | class WrongAnimal 7 | { 8 | protected: 9 | std::string _type; 10 | 11 | public: 12 | WrongAnimal(); 13 | WrongAnimal(std::string type); 14 | WrongAnimal(const WrongAnimal &to_copy); 15 | WrongAnimal &operator=(const WrongAnimal &original); 16 | virtual ~WrongAnimal(); 17 | 18 | std::string getType() const; 19 | virtual void makeSound() const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/inc/WrongCat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WRONGCAT_HPP 2 | #define WRONGCAT_HPP 3 | 4 | #include "WrongAnimal.hpp" 5 | 6 | class WrongCat : public WrongAnimal 7 | { 8 | public: 9 | WrongCat(); 10 | WrongCat(const WrongCat ©); 11 | WrongCat &operator=(const WrongCat &original); 12 | virtual ~WrongCat(); 13 | 14 | void makeSound() const; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex02/src/Brain.cpp: -------------------------------------------------------------------------------- 1 | #include "Brain.hpp" 2 | 3 | Brain::Brain() 4 | { 5 | std::cout << "Brain constructor called" << std::endl; 6 | } 7 | 8 | Brain::Brain(const Brain ©) 9 | { 10 | std::cout << "Brain copy constructor called" << std::endl; 11 | *this = copy; 12 | } 13 | 14 | Brain &Brain::operator=(const Brain &original) 15 | { 16 | if (this != &original) 17 | for (int i = 0; i < 100; i++) 18 | this->_ideas[i] = original._ideas[i]; 19 | return *this; 20 | } 21 | 22 | Brain::~Brain() 23 | { 24 | std::cout << "Brain destructor called" << std::endl; 25 | } 26 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/AMateria.hpp: -------------------------------------------------------------------------------- 1 | #ifndef AMATERIA_HPP 2 | #define AMATERIA_HPP 3 | 4 | #include 5 | #include "ICharacter.hpp" 6 | 7 | class ICharacter; 8 | 9 | class AMateria 10 | { 11 | protected: 12 | std::string type; 13 | 14 | public: 15 | AMateria(); 16 | AMateria(std::string const &type); 17 | AMateria(const AMateria &cpy); 18 | virtual ~AMateria(); 19 | 20 | AMateria &operator=(const AMateria &obj); 21 | 22 | std::string const &getType() const; // Returns the materia type 23 | 24 | virtual AMateria *clone() const = 0; 25 | virtual void use(ICharacter &target); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/Character.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHARACTER_HPP 2 | #define CHARACTER_HPP 3 | 4 | #include "ICharacter.hpp" 5 | class Character : public ICharacter 6 | { 7 | private: 8 | std::string _name; 9 | AMateria *_inventory[4]; 10 | 11 | public: 12 | Character(); 13 | Character(std::string name); 14 | Character(const Character &cpy); 15 | virtual ~Character(); 16 | 17 | Character &operator=(const Character &obj); 18 | 19 | const std::string &getName(void) const; 20 | 21 | void equip(AMateria *m); 22 | void unequip(int idx); 23 | void use(int idx, ICharacter &target); 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/Cure.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CURE_HPP 2 | #define CURE_HPP 3 | 4 | #include "AMateria.hpp" 5 | 6 | class Cure : public AMateria 7 | { 8 | public: 9 | Cure(); 10 | Cure(const Cure &cpy); 11 | virtual ~Cure(); 12 | 13 | Cure &operator=(const Cure &obj); 14 | 15 | virtual Cure *clone() const; 16 | virtual void use(ICharacter &target); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/ICharacter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ICHARACTER_HPP 2 | #define ICHARACTER_HPP 3 | 4 | #include "AMateria.hpp" 5 | 6 | class AMateria; 7 | 8 | class ICharacter 9 | { 10 | public: 11 | virtual ~ICharacter() {} 12 | virtual std::string const &getName() const = 0; 13 | virtual void equip(AMateria *m) = 0; 14 | virtual void unequip(int idx) = 0; 15 | virtual void use(int idx, ICharacter &target) = 0; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/IMateriaSource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef IMATERIASOURCE_HPP 2 | #define IMATERIASOURCE_HPP 3 | 4 | class IMateriaSource 5 | { 6 | public: 7 | virtual ~IMateriaSource(void) {} 8 | 9 | virtual void learnMateria(AMateria *) = 0; 10 | virtual AMateria *createMateria(const std::string &type) = 0; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/Ice.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ICE_HPP 2 | #define ICE_HPP 3 | 4 | #include "AMateria.hpp" 5 | 6 | class Ice : public AMateria 7 | { 8 | public: 9 | Ice(); 10 | Ice(const Ice &cpy); 11 | virtual ~Ice(); 12 | 13 | Ice &operator=(const Ice &obj); 14 | 15 | virtual Ice *clone() const; 16 | virtual void use(ICharacter &target); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/inc/MateriaSource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MATERIASOURCE_HPP 2 | #define MATERIASOURCE_HPP 3 | 4 | #include "AMateria.hpp" 5 | #include "IMateriaSource.hpp" 6 | 7 | class MateriaSource : public IMateriaSource 8 | { 9 | private: 10 | AMateria *_materia[4]; 11 | 12 | public: 13 | MateriaSource(); 14 | MateriaSource(const MateriaSource &cpy); 15 | virtual ~MateriaSource(); 16 | 17 | MateriaSource &operator=(const MateriaSource &obj); 18 | 19 | AMateria *createMateria(std::string const &type); 20 | void learnMateria(AMateria *); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/main.cpp: -------------------------------------------------------------------------------- 1 | #include "inc/MateriaSource.hpp" 2 | #include "inc/Ice.hpp" 3 | #include "inc/Cure.hpp" 4 | #include "inc/Character.hpp" 5 | 6 | int main() 7 | { 8 | IMateriaSource* src = new MateriaSource(); 9 | src->learnMateria(new Ice()); 10 | src->learnMateria(new Cure()); 11 | ICharacter* me = new Character("me"); 12 | AMateria* tmp; 13 | tmp = src->createMateria("ice"); 14 | me->equip(tmp); 15 | tmp = src->createMateria("cure"); 16 | me->equip(tmp); 17 | ICharacter* bob = new Character("bob"); 18 | me->use(0, *bob); 19 | me->use(1, *bob); 20 | delete bob; 21 | delete me; 22 | delete src; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/src/Cure.cpp: -------------------------------------------------------------------------------- 1 | #include "../inc/Cure.hpp" 2 | 3 | Cure::Cure(void) : AMateria("cure") {} 4 | 5 | Cure::Cure(const Cure &cpy) : AMateria("cure") 6 | { 7 | *this = cpy; 8 | } 9 | 10 | Cure::~Cure(void) {} 11 | 12 | Cure &Cure::operator=(const Cure &obj) 13 | { 14 | (void)obj; 15 | return (*this); 16 | } 17 | 18 | Cure *Cure::clone() const 19 | { 20 | return (new Cure(*this)); 21 | } 22 | 23 | void Cure::use(ICharacter &target) 24 | { 25 | std::cout << "* heals " << target.getName() << "'s wounds *" << std::endl; 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_4/CPP_Module_0-4/Module_04/ex03/src/Ice.cpp: -------------------------------------------------------------------------------- 1 | #include "../inc/Ice.hpp" 2 | 3 | Ice::Ice(void) : AMateria("ice") {} 4 | 5 | Ice::Ice(const Ice &cpy) : AMateria("ice") 6 | { 7 | *this = cpy; 8 | } 9 | 10 | Ice::~Ice(void){}; 11 | 12 | Ice &Ice::operator=(const Ice &obj) 13 | { 14 | (void)obj; 15 | return (*this); 16 | } 17 | 18 | Ice *Ice::clone() const 19 | { 20 | return (new Ice(*this)); 21 | } 22 | 23 | void Ice::use(ICharacter &target) 24 | { 25 | std::cout << "* shoots an ice bolt at " << target.getName() << "*" << std::endl; 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/NetPractice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/NetPractice.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/ip1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/ip1.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/ip_version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/ip_version.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level10_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level10_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level1_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level1_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level2_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level2_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level3_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level3_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level4_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level4_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level5_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level5_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level6_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level6_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level7_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level7_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level8_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level8_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/level9_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/level9_paint.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/mask1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/mask1.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/route1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/route1.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/routing_table1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/routing_table1.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/switch1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/switch1.png -------------------------------------------------------------------------------- /42-cursus/circle_4/NetPractice/assets/tcp-ip-stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/NetPractice/assets/tcp-ip-stack.png -------------------------------------------------------------------------------- /42-cursus/circle_4/exam_rank_04/assets/exam_rank_04_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/exam_rank_04/assets/exam_rank_04_header.png -------------------------------------------------------------------------------- /42-cursus/circle_4/exam_rank_04/assets/grademe_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_4/exam_rank_04/assets/grademe_01.png -------------------------------------------------------------------------------- /42-cursus/circle_4/exam_rank_04/microshell.h: -------------------------------------------------------------------------------- 1 | #ifndef MICROSHELL_H 2 | #define MICROSHELL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_05/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Bureaucrat.hpp" 2 | #include "Form.hpp" 3 | 4 | int main(void) 5 | { 6 | try 7 | { 8 | Bureaucrat bureaucrat("ash", 11); 9 | Form form("formName", 10); 10 | 11 | bureaucrat.signForm(form); 12 | 13 | std::cout << form << std::endl; 14 | } 15 | catch (std::exception &e) 16 | { 17 | std::cout << e.what() << std::endl; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex02/inc/PresidentialPardonForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PRESIDENTIALPARDONFORM_HPP 2 | #define PRESIDENTIALPARDONFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | 6 | class PresidentialPardonForm : public AForm 7 | { 8 | private: 9 | std::string _target; 10 | PresidentialPardonForm(void); 11 | 12 | public: 13 | PresidentialPardonForm(const std::string &target); 14 | PresidentialPardonForm(const PresidentialPardonForm ©); 15 | ~PresidentialPardonForm(void); 16 | 17 | PresidentialPardonForm &operator=(const PresidentialPardonForm &obj); 18 | 19 | void execute(const Bureaucrat &executor) const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex02/inc/RobotomyRequestForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ROBOTOMYREQUESTFORM_HPP 2 | #define ROBOTOMYREQUESTFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | 6 | class RobotomyRequestForm : public AForm 7 | { 8 | private: 9 | const std::string _target; 10 | RobotomyRequestForm(); 11 | 12 | public: 13 | RobotomyRequestForm(const std::string &target); 14 | RobotomyRequestForm(const RobotomyRequestForm &src); 15 | ~RobotomyRequestForm(); 16 | 17 | RobotomyRequestForm &operator=(RobotomyRequestForm &obj); 18 | 19 | void execute(const Bureaucrat &executor) const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex02/inc/ShrubberyCreationForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SHRUBBERYCREATIONFORM_HPP 2 | #define SHRUBBERYCREATIONFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | #include 6 | 7 | class ShrubberyCreationForm : public AForm 8 | { 9 | 10 | private: 11 | const std::string _target; 12 | ShrubberyCreationForm(); 13 | 14 | public: 15 | ShrubberyCreationForm(const std::string &target); 16 | ShrubberyCreationForm(const ShrubberyCreationForm &src); 17 | ~ShrubberyCreationForm(); 18 | 19 | ShrubberyCreationForm &operator=(ShrubberyCreationForm &obj); 20 | 21 | void execute(const Bureaucrat &executor) const; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex03/inc/Intern.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INTERN_HPP 2 | #define INTERN_HPP 3 | 4 | #include 5 | #include "AForm.hpp" 6 | 7 | class Intern 8 | { 9 | public: 10 | Intern(void); 11 | Intern(const Intern &to_copy); 12 | virtual ~Intern(void); 13 | 14 | Intern &operator=(const Intern &obj); 15 | 16 | AForm *makeForm(std::string name, std::string target); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex03/inc/PresidentialPardonForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PRESIDENTIALPARDONFORM_HPP 2 | #define PRESIDENTIALPARDONFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | 6 | class PresidentialPardonForm : public AForm 7 | { 8 | private: 9 | std::string _target; 10 | PresidentialPardonForm(void); 11 | 12 | public: 13 | PresidentialPardonForm(const std::string &target); 14 | PresidentialPardonForm(const PresidentialPardonForm ©); 15 | virtual ~PresidentialPardonForm(void); 16 | 17 | PresidentialPardonForm &operator=(const PresidentialPardonForm &obj); 18 | 19 | void execute(const Bureaucrat &executor) const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex03/inc/RobotomyRequestForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ROBOTOMYREQUESTFORM_HPP 2 | #define ROBOTOMYREQUESTFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | 6 | class RobotomyRequestForm : public AForm 7 | { 8 | private: 9 | const std::string _target; 10 | RobotomyRequestForm(); 11 | 12 | public: 13 | RobotomyRequestForm(const std::string &target); 14 | RobotomyRequestForm(const RobotomyRequestForm &src); 15 | virtual ~RobotomyRequestForm(); 16 | 17 | RobotomyRequestForm &operator=(RobotomyRequestForm &obj); 18 | 19 | void execute(const Bureaucrat &executor) const; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_05/ex03/inc/ShrubberyCreationForm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SHRUBBERYCREATIONFORM_HPP 2 | #define SHRUBBERYCREATIONFORM_HPP 3 | 4 | #include "AForm.hpp" 5 | #include 6 | 7 | class ShrubberyCreationForm : public AForm 8 | { 9 | 10 | private: 11 | const std::string _target; 12 | ShrubberyCreationForm(); 13 | 14 | public: 15 | ShrubberyCreationForm(const std::string &target); 16 | ShrubberyCreationForm(const ShrubberyCreationForm &src); 17 | virtual ~ShrubberyCreationForm(); 18 | 19 | ShrubberyCreationForm &operator=(ShrubberyCreationForm &obj); 20 | 21 | void execute(const Bureaucrat &executor) const; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_06/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex00/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ScalarConverter.hpp" 2 | 3 | int main(int argc, char **argv) 4 | { 5 | if (argc == 2) 6 | { 7 | ScalarConverter::convert(argv[1]); 8 | return 0; 9 | } 10 | std::cout << "Error: usage: ./ScalarConverter " << std::endl; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex01/Data.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DATA_HPP 2 | #define DATA_HPP 3 | 4 | #include 5 | 6 | typedef struct s_data 7 | { 8 | std::string dummy_str; 9 | } data_t; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex01/Serialization.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SERIALIZATION_HPP 2 | #define SERIALIZATION_HPP 3 | 4 | #include 5 | #include 6 | #include "Data.hpp" 7 | 8 | class Serialization 9 | { 10 | private: 11 | Serialization(); 12 | Serialization(const Serialization &rhs); 13 | ~Serialization(); 14 | 15 | Serialization &operator=(const Serialization &rhs); 16 | 17 | public: 18 | static uintptr_t serialize(data_t *ptr); 19 | static data_t *deserialize(uintptr_t raw); 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex02/inc/Base.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BASE_HPP 2 | #define BASE_HPP 3 | 4 | class Base 5 | { 6 | public: 7 | virtual ~Base(); 8 | }; 9 | 10 | #define RED "\033[31m" 11 | #define END "\033[0m" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex02/inc/Class_A.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CLASS_A_HPP 3 | #define CLASS_A_HPP 4 | 5 | #include "Base.hpp" 6 | 7 | class ClassA : public Base 8 | { 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex02/inc/Class_B.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLASS_B_HPP 2 | #define CLASS_B_HPP 3 | 4 | #include "Base.hpp" 5 | 6 | class ClassB : public Base 7 | { 8 | }; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex02/inc/Class_C.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLASS_C_HPP 2 | #define CLASS_C_HPP 3 | 4 | #include "Base.hpp" 5 | 6 | class ClassC : public Base 7 | { 8 | }; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_06/ex02/src/Base.cpp: -------------------------------------------------------------------------------- 1 | #include "../inc/Base.hpp" 2 | #include 3 | 4 | Base::~Base() 5 | { 6 | std::cout << RED << "Base destructor called" << END << std::endl; 7 | return; 8 | } 9 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_07/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_07/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_07/ex00/whatever.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template // defines, T is a template 6 | 7 | const T &max(const T &x, const T &y) 8 | { 9 | return (x >= y ? x : y); 10 | } 11 | 12 | template // defines, U is a template 13 | 14 | const U &min(const U &x, const U &y) 15 | { 16 | return (x <= y ? x : y); 17 | } 18 | 19 | template 20 | 21 | void swap(V &x, V &y) 22 | { 23 | V temp = x; 24 | x = y; 25 | y = temp; 26 | } 27 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_08/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_08/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_08/ex00/easyfind.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class NotFoundException: public std::exception 9 | { 10 | public: 11 | virtual const char *what() const throw() 12 | { 13 | return ("Not found"); 14 | } 15 | }; 16 | 17 | template< typename T> 18 | typename T::iterator easyfind(T &in, int i) 19 | { 20 | typename T::iterator it; 21 | it = find(in.begin(), in.end(), i); 22 | if (it == in.end()) 23 | { 24 | throw (NotFoundException()); 25 | } 26 | return (it); 27 | } 28 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_09/en.subject.pdf -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex00/main.cpp: -------------------------------------------------------------------------------- 1 | #include "./BitcoinExchange.hpp" 2 | 3 | int main(int argc, char **argv) 4 | { 5 | if (argc < 2) 6 | { 7 | std::cout << "Error: could not open file." << std::endl; 8 | return (1); 9 | } 10 | try 11 | { 12 | if (argc > 2) 13 | throw static_cast("too many args"); 14 | BitcoinExchange bitcoin; 15 | bitcoin.handleInputFile(argv[1]); 16 | // bitcoin.printMap(); 17 | } 18 | catch (std::string error) 19 | { 20 | std::cout << "Error : " << error << std::endl; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex00/test/emptyData.txt: -------------------------------------------------------------------------------- 1 | date | value 2 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex00/test/emptyFile.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/42-cursus/circle_5/CPP_Module_5-9/Module_09/ex00/test/emptyFile.txt -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex00/test/input.txt: -------------------------------------------------------------------------------- 1 | date | value 2 | 2011-01-03 | 3 3 | 2011-01-03 | 2 4 | 2011-01-03 | 1 5 | 2011-01-03 | 1.2 6 | 2011-01-09 | 1 7 | 2012-01-11 | -1 8 | 2001-42-42 9 | 2012-01-11 | 1 10 | 2012-01-11 | 2147483648 11 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex01/RPN.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RPN_H 2 | #define RPN_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class RPN 10 | { 11 | private: 12 | struct 13 | { 14 | double first; 15 | double second; 16 | } operand; 17 | double result; 18 | std::stack Stack; 19 | 20 | public: 21 | RPN(); 22 | RPN(std::string rpn); 23 | RPN(const RPN &src); 24 | RPN &operator=(const RPN &src); 25 | ~RPN(); 26 | bool operatorIsValid(char Operator); 27 | void checkRpn(std::string &rpn, int index); 28 | }; 29 | #endif 30 | -------------------------------------------------------------------------------- /42-cursus/circle_5/CPP_Module_5-9/Module_09/ex01/main.cpp: -------------------------------------------------------------------------------- 1 | #include "./RPN.hpp" 2 | 3 | int main(int argc, char **argv) 4 | { 5 | try 6 | { 7 | if (argc != 2) 8 | { 9 | throw ": invalid number of argumnts"; 10 | } 11 | RPN rpn(argv[1]); 12 | } 13 | catch (const char *error) 14 | { 15 | std::cout << "Error" << error << std::endl; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /42-discovery_web/README.md: -------------------------------------------------------------------------------- 1 | Piscine Web Discovery es una piscina de 5 días, para dar a conocer a 42 personas que tengan curiosidad y quieren dar un giro a su vida. No importa si sabes programar o no, ni la edad. En esta Piscine inmersiva las personas participantes han aprendido HTML, CSS y JavaScript, así como la innovadora metodología de 42. Una experiencia disruptiva presencial que les ha permitido experimentar lo que es 42 de forma 100% gratuita. 2 | 3 | ### RUSH - (proyecto final) 4 | 5 | [![proyecto final](https://github.com/zafraedu/42PiscineDiscoveryWeb-rush/blob/main/img/freelancer-portfolio-template.jpg)](https://zafraedu.github.io/42PiscineDiscoveryWeb-rush/) 6 | 7 | [Click aquí](https://github.com/zafraedu/42PiscineDiscoveryWeb-rush) para ir al repositorio del proyecto. 8 | -------------------------------------------------------------------------------- /42-discovery_web/cell0/ex01/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /42-discovery_web/cell0/ex02/midLS: -------------------------------------------------------------------------------- 1 | ls -m 2 | -------------------------------------------------------------------------------- /42-discovery_web/cell0/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls | wc -l 3 | -------------------------------------------------------------------------------- /42-discovery_web/cell0/ex04/argv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# -eq 0 ]; then #verifica si se proporciona argumentos; 3 | echo No arguments supplied 4 | else 5 | count=0 #assignar un contador para los args a '0'; 6 | for arg in $@; do # $@ == todos los args 7 | if [ $count -lt 3 ]; then #si count es < 3; 8 | echo $arg #imprimir el argumento; 9 | ((count++)) #incrementar el contador; 10 | else 11 | break #si no (sale del bucle for); 12 | fi 13 | done 14 | fi 15 | -------------------------------------------------------------------------------- /42-discovery_web/cell0/ex05/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ]; then 4 | echo No arguments supplied 5 | else 6 | for arg in $@; do 7 | mkdir "ex$arg" 8 | done 9 | fi 10 | -------------------------------------------------------------------------------- /42-discovery_web/cell1/ex00/helloworld.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 42 | cell01 | ex00 8 | 9 | 10 | 11 |

Hello World

12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /42-discovery_web/cell1/ex01/piscineweb.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 42 | cell01 | ex01 8 | 9 | 10 | 11 |

Piscine Web

12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /42-discovery_web/cell2/ex00/responsive.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | padding: 0; 4 | width: 100%; 5 | height: 100%; 6 | } 7 | 8 | table { 9 | width: 100%; 10 | height: 100%; 11 | border-collapse: collapse; 12 | } 13 | 14 | .box1 { 15 | background-color: darkseagreen; 16 | } 17 | 18 | .box2 { 19 | background-color: salmon; 20 | } 21 | 22 | td { 23 | text-align: center; 24 | width: 50%; 25 | font-size: 2em; 26 | font-family: Arial, Helvetica, sans-serif; 27 | border: 1px solid black; 28 | } 29 | -------------------------------------------------------------------------------- /42-discovery_web/cell2/ex00/responsive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 42 | cell02 | ex00 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
First cellSecond cell
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /42-discovery_web/cell2/ex02/parallax.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 42 | cell02 | ex02 7 | 8 | 9 | 10 |
11 |

Jungle

12 |
13 |

14 | “Look deep into nature, and then you will understand everything 15 | better.” 16 |

17 |
18 |

Savanna

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex00/background.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | transition: all 300ms ease-in-out; 9 | } 10 | 11 | main { 12 | height: 100vh; 13 | display: flex; 14 | flex-direction: column; 15 | justify-content: center; 16 | align-items: center; 17 | } 18 | 19 | main input { 20 | width: 6rem; 21 | height: 6rem; 22 | cursor: pointer; 23 | border: 1px solid #ccc; 24 | border-radius: 50%; 25 | font-size: large; 26 | font-weight: 600; 27 | } 28 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex00bis/background.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | transition: all 200ms ease-in-out; 9 | } 10 | 11 | main { 12 | height: 100vh; 13 | display: flex; 14 | flex-direction: column; 15 | justify-content: center; 16 | align-items: center; 17 | } 18 | 19 | main input { 20 | width: 6rem; 21 | height: 6rem; 22 | cursor: pointer; 23 | border: 1px solid #ccc; 24 | border-radius: 50%; 25 | font-size: large; 26 | font-weight: 600; 27 | } 28 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex00bis/background.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 42 | cell03 | ex00 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex00bis/background.js: -------------------------------------------------------------------------------- 1 | //! jQuery 2 | $(document).ready(() => { 3 | $("#changeColorBtn").click(() => { 4 | $("body").css("background", () => { 5 | return "#" + Math.floor(Math.random() * 16777215).toString(16); 6 | }); 7 | }); 8 | }); 9 | //! no jQuery 10 | // function changeColor() { 11 | // const letras = "0123456789ABCDEF"; 12 | // let color = "#"; 13 | // for (let i = 0; i < 6; i++) { 14 | // color += letras[Math.floor(Math.random() * 16)]; 15 | // } 16 | // document.body.style.backgroundColor = color; 17 | // } 18 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex01bis/balloon.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | margin: 0; 4 | padding: 0; 5 | } 6 | body { 7 | height: 100vh; 8 | display: flex; 9 | justify-content: center; 10 | align-items: center; 11 | } 12 | #circulo { 13 | width: 200px; 14 | height: 200px; 15 | background-color: red; 16 | border-radius: 50%; 17 | cursor: pointer; 18 | transition: background-color 0.3s, width 0.3s, height 0.3s; 19 | } 20 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex01bis/balloon.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 42 | cell03 | ex01 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /42-discovery_web/cell3/ex04/ex03bis/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 42 | cell03 | ex03 8 | 9 | 10 | 11 | 12 |
13 |

To do list

14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /42-piscine/C00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | /* 8 | int main(void) 9 | { 10 | ft_putchar('X'); 11 | } 12 | */ 13 | -------------------------------------------------------------------------------- /42-piscine/C00/ex01/ft_print_alphabet.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_print_alphabet(void) 4 | { 5 | char a; 6 | 7 | a = 'a'; 8 | while (a <= 'z') 9 | { 10 | write(1, &a, 1); 11 | a++; 12 | } 13 | } 14 | /* 15 | int main(void) 16 | { 17 | ft_print_alphabet(); 18 | return (0); 19 | } 20 | */ 21 | -------------------------------------------------------------------------------- /42-piscine/C00/ex02/ft_print_reverse_alphabet.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_print_reverse_alphabet(void) 4 | { 5 | char z; 6 | 7 | z = 'z'; 8 | while (z >= 'a') 9 | { 10 | write(1, &z, 1); 11 | z--; 12 | } 13 | } 14 | /* 15 | int main(void) 16 | { 17 | ft_print_reverse_alphabet(); 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /42-piscine/C00/ex03/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_print_numbers(void) 4 | { 5 | char number; 6 | 7 | number = '0'; 8 | while (number <= '9') 9 | { 10 | write(1, &number, 1); 11 | number++; 12 | } 13 | } 14 | /* 15 | int main(void) 16 | { 17 | ft_print_numbers(); 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /42-piscine/C00/ex04/ft_is_negative.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_is_negative(int n) 4 | { 5 | char negative; 6 | char positive; 7 | 8 | negative = 'N'; 9 | positive = 'P'; 10 | if (n >= 0) 11 | write(1, &positive, 1); 12 | else 13 | write(1, &negative, 1); 14 | } 15 | /* 16 | int main(void) 17 | { 18 | ft_is_negative(0); 19 | ft_is_negative(1); 20 | ft_is_negative(-3); 21 | return (0); 22 | } 23 | */ 24 | -------------------------------------------------------------------------------- /42-piscine/C00/ex05/ft_print_comb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | 8 | void function(char d1, char d2, char d3) 9 | { 10 | print(d1); 11 | print(d2); 12 | print(d3); 13 | if (d1 < '7') 14 | write(1, ", ", 2); 15 | } 16 | 17 | void ft_print_comb(void) 18 | { 19 | char d1; 20 | char d2; 21 | char d3; 22 | 23 | d1 = '0'; 24 | while (d1 <= '7') 25 | { 26 | d2 = d1 + 1; 27 | while (d2 <= '8') 28 | { 29 | d3 = d2 + 1; 30 | while (d3 <= '9') 31 | { 32 | function(d1, d2, d3); 33 | d3++; 34 | } 35 | d2++; 36 | } 37 | d1++; 38 | } 39 | } 40 | /* 41 | int main(void) 42 | { 43 | ft_print_comb(); 44 | return (0); 45 | } 46 | */ 47 | -------------------------------------------------------------------------------- /42-piscine/C00/ex06/ft_print_comb2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print(char a, char b) 4 | { 5 | write(1, &a, 1); 6 | write(1, &b, 1); 7 | } 8 | 9 | void ft_print_comb2(void) 10 | { 11 | int a; 12 | int b; 13 | 14 | a = 0; 15 | while (a <= 98) 16 | { 17 | b = a + 1; 18 | while (b <= 99) 19 | { 20 | print((a / 10) + '0', (a % 10) + '0'); 21 | write(1, " ", 1); 22 | print((b / 10) + '0', (b % 10) + '0'); 23 | if (a != 98) 24 | write(1, ", ", 2); 25 | b++; 26 | } 27 | a++; 28 | } 29 | } 30 | /* 31 | int main(void) 32 | { 33 | ft_print_comb2(); 34 | return (0); 35 | } 36 | */ 37 | -------------------------------------------------------------------------------- /42-piscine/C00/ex07/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | 8 | void ft_putnbr(int nb) 9 | { 10 | long num; 11 | 12 | num = nb; 13 | if (num < 0) 14 | { 15 | print('-'); 16 | num = -num; 17 | } 18 | if (num > 9) 19 | { 20 | ft_putnbr(num / 10); 21 | ft_putnbr(num % 10); 22 | } 23 | else 24 | print(num + '0'); 25 | } 26 | /* 27 | int main(void) 28 | { 29 | ft_putnbr(0); 30 | return (0); 31 | } 32 | */ 33 | -------------------------------------------------------------------------------- /42-piscine/C01/ex00/ft_ft.c: -------------------------------------------------------------------------------- 1 | void ft_ft(int *nbr) 2 | { 3 | *nbr = 42; 4 | } 5 | /* 6 | #include 7 | 8 | int main(void){ 9 | int number; 10 | ft_ft(&number); 11 | printf("%d", number); 12 | } 13 | */ 14 | -------------------------------------------------------------------------------- /42-piscine/C01/ex01/ft_ultimate_ft.c: -------------------------------------------------------------------------------- 1 | void ft_ultimate_ft(int *********nbr) 2 | { 3 | *********nbr = 42; 4 | } 5 | /* 6 | #include 7 | 8 | int main(void){ 9 | int nbr; 10 | int *p_nbr1; 11 | int **p_nbr2; 12 | int ***p_nbr3; 13 | int ****p_nbr4; 14 | int *****p_nbr5; 15 | int ******p_nbr6; 16 | int *******p_nbr7; 17 | int ********p_nbr8; 18 | int *********p_nbr9; 19 | 20 | nbr = 21; 21 | 22 | p_nbr9 = &p_nbr8; 23 | p_nbr8 = &p_nbr7; 24 | p_nbr7 = &p_nbr6; 25 | p_nbr6 = &p_nbr5; 26 | p_nbr5 = &p_nbr4; 27 | p_nbr4 = &p_nbr3; 28 | p_nbr3 = &p_nbr2; 29 | p_nbr2 = &p_nbr1; 30 | p_nbr1 = &nbr; 31 | 32 | printf("%d\n", nbr); 33 | ft_ultimate_ft(p_nbr9); 34 | printf("%d\n", nbr); 35 | } 36 | */ 37 | -------------------------------------------------------------------------------- /42-piscine/C01/ex02/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int c; 4 | 5 | c = *a; 6 | *a = *b; 7 | *b = c; 8 | } 9 | /* 10 | #include 11 | 12 | int main(void){ 13 | int a = 2; 14 | int b = 3; 15 | ft_swap(&a, &b); 16 | printf("%d\n%d\n",a,b); 17 | } 18 | */ 19 | -------------------------------------------------------------------------------- /42-piscine/C01/ex03/ft_div_mod.c: -------------------------------------------------------------------------------- 1 | void ft_div_mod(int a, int b, int *div, int *mod) 2 | { 3 | *div = a / b; 4 | *mod = a % b; 5 | } 6 | /* 7 | #include 8 | 9 | int main(void){ 10 | int div; 11 | int mod; 12 | ft_div_mod(15, 3, &div, &mod); 13 | printf("%d | %d", div, mod); 14 | } 15 | */ 16 | -------------------------------------------------------------------------------- /42-piscine/C01/ex04/ft_ultimate_div_mod.c: -------------------------------------------------------------------------------- 1 | void ft_ultimate_div_mod(int *a, int *b) 2 | { 3 | int c; 4 | 5 | c = *a; 6 | *a = *a / *b; 7 | *b = c % *b; 8 | } 9 | /* 10 | #include 11 | 12 | int main(void){ 13 | int a = 12; 14 | int b = 3; 15 | ft_ultimate_div_mod(&a, &b); 16 | printf("%d | %d", a, b); 17 | } 18 | */ 19 | -------------------------------------------------------------------------------- /42-piscine/C01/ex05/ft_putstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) 4 | { 5 | int count; 6 | 7 | count = 0; 8 | while (str[count] != '\0') 9 | { 10 | write(1, &str[count], 1); 11 | count++; 12 | } 13 | } 14 | /* 15 | int main(void){ 16 | char *word = "Hola"; 17 | ft_putstr(word); 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /42-piscine/C01/ex06/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int count; 4 | 5 | count = 0; 6 | while (str[count] != '\0') 7 | { 8 | count++; 9 | } 10 | return (count); 11 | } 12 | /* 13 | #include 14 | 15 | int main(void){ 16 | char *c = "Hola"; 17 | printf("%d", ft_strlen(c)); 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /42-piscine/C01/ex07/ft_rev_int_tab.c: -------------------------------------------------------------------------------- 1 | void ft_rev_int_tab(int *tab, int size) 2 | { 3 | int i; 4 | int swap; 5 | 6 | i = 0; 7 | while (i < (size / 2)) 8 | { 9 | swap = tab[i]; 10 | tab[i] = tab[size - 1 - i]; 11 | tab[size - 1 - i] = swap; 12 | i++; 13 | } 14 | } 15 | /* 16 | #include 17 | 18 | int main(void){ 19 | int tab[6] = {0,1,2,3,4,5}; 20 | int size = 6; 21 | ft_rev_int_tab(tab, size); 22 | 23 | int i = 0; 24 | while(i <= (size - 1)){ 25 | printf("%d", tab[i]); 26 | if(i < size - 1) 27 | printf(", "); 28 | i++; 29 | } 30 | } 31 | */ 32 | -------------------------------------------------------------------------------- /42-piscine/C01/ex08/ft_sort_int_tab.c: -------------------------------------------------------------------------------- 1 | void ft_sort_int_tab(int *tab, int size) 2 | { 3 | int i; 4 | int swap; 5 | 6 | while (size >= 0) 7 | { 8 | i = 0; 9 | while (i < size - 1) 10 | { 11 | if (tab[i] > tab[i + 1]) 12 | { 13 | swap = tab[i]; 14 | tab[i] = tab[i + 1]; 15 | tab[i + 1] = swap; 16 | } 17 | i++; 18 | } 19 | size--; 20 | } 21 | } 22 | /* 23 | #include 24 | 25 | int main(void){ 26 | int tab[6] = {4, 2, 7, 5, 3, 6}; 27 | int size = 6; 28 | ft_sort_int_tab(tab, size); 29 | 30 | int i = 0; 31 | while(i < size){ 32 | printf("%d", tab[i]); 33 | if(i < size -1) 34 | printf(", "); 35 | i++; 36 | } 37 | } 38 | */ 39 | -------------------------------------------------------------------------------- /42-piscine/C02/ex00/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | char *ft_strcpy(char *dest, char *src) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (src[i] != '\0') 7 | { 8 | dest[i] = src[i]; 9 | i++; 10 | } 11 | dest[i] = '\0'; 12 | return (dest); 13 | } 14 | /* 15 | #include 16 | #include 17 | 18 | int main(void){ 19 | char dest[7] = "abcdef"; 20 | char src[7] = "Origen"; 21 | printf("%s\n", ft_strcpy(dest, src)); 22 | strcpy(dest, src); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /42-piscine/C02/ex01/ft_strncpy.c: -------------------------------------------------------------------------------- 1 | char *ft_strncpy(char *dest, char *src, unsigned int n) 2 | { 3 | unsigned int i; 4 | 5 | i = 0; 6 | while (src[i] != '\0' && i < n) 7 | { 8 | dest[i] = src[i]; 9 | i++; 10 | } 11 | while (i < n) 12 | { 13 | dest[i] = '\0'; 14 | i++; 15 | } 16 | return (dest); 17 | } 18 | /* 19 | #include 20 | #include 21 | 22 | int main(void){ 23 | char src[8] = "Eduardo"; 24 | char dest[8]; 25 | 26 | printf("%s\n", ft_strncpy(dest, src, 3)); 27 | printf("%s\n", strncpy(dest, src, 3)); 28 | } 29 | */ 30 | -------------------------------------------------------------------------------- /42-piscine/C02/ex02/ft_str_is_alpha.c: -------------------------------------------------------------------------------- 1 | char is_uppercase(char c) 2 | { 3 | return (c >= 'A' && c <= 'Z'); 4 | } 5 | 6 | char is_lowercase(char c) 7 | { 8 | return (c >= 'a' && c <= 'z'); 9 | } 10 | 11 | int ft_str_is_alpha(char *str) 12 | { 13 | int i; 14 | 15 | i = 0; 16 | while (str[i] != '\0') 17 | { 18 | if (is_uppercase(str[i]) || is_lowercase(str[i])) 19 | i++; 20 | else 21 | return (0); 22 | } 23 | return (1); 24 | } 25 | /* 26 | #include 27 | 28 | int main(void){ 29 | printf("%d\n", ft_str_is_alpha("")); 30 | printf("%d\n", ft_str_is_alpha("abcdefgh")); 31 | printf("%d\n", ft_str_is_alpha("ABCDEFGH")); 32 | printf("%d\n", ft_str_is_alpha("aBcDeFgG")); 33 | printf("%d\n", ft_str_is_alpha("a4b*c")); 34 | } 35 | */ 36 | -------------------------------------------------------------------------------- /42-piscine/C02/ex03/ft_str_is_numeric.c: -------------------------------------------------------------------------------- 1 | int ft_str_is_numeric(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= '0' && str[i] <= '9') 9 | i++; 10 | else 11 | return (0); 12 | } 13 | return (1); 14 | } 15 | /* 16 | #include 17 | 18 | int main(void){ 19 | printf("%d\n", ft_str_is_numeric("")); 20 | printf("%d\n", ft_str_is_numeric("1234")); 21 | printf("%d\n", ft_str_is_numeric("12a3")); 22 | printf("%d\n", ft_str_is_numeric("abcd")); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /42-piscine/C02/ex04/ft_str_is_lowercase.c: -------------------------------------------------------------------------------- 1 | int ft_str_is_lowercase(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= 'a' && str[i] <= 'z') 9 | i++; 10 | else 11 | return (0); 12 | } 13 | return (1); 14 | } 15 | /* 16 | #include 17 | 18 | int main(void){ 19 | printf("%d\n", ft_str_is_lowercase("")); 20 | printf("%d\n", ft_str_is_lowercase("abcd")); 21 | printf("%d\n", ft_str_is_lowercase("abCd")); 22 | printf("%d\n", ft_str_is_lowercase("ABCD")); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /42-piscine/C02/ex05/ft_str_is_uppercase.c: -------------------------------------------------------------------------------- 1 | int ft_str_is_uppercase(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= 'A' && str[i] <= 'Z') 9 | i++; 10 | else 11 | return (0); 12 | } 13 | return (1); 14 | } 15 | /* 16 | #include 17 | 18 | int main(void){ 19 | printf("%d\n", ft_str_is_uppercase("")); 20 | printf("%d\n", ft_str_is_uppercase("ABCD")); 21 | printf("%d\n", ft_str_is_uppercase("AbCD")); 22 | printf("%d\n", ft_str_is_uppercase("aBCD")); 23 | printf("%d\n", ft_str_is_uppercase("Ab12")); 24 | } 25 | */ 26 | -------------------------------------------------------------------------------- /42-piscine/C02/ex06/ft_str_is_printable.c: -------------------------------------------------------------------------------- 1 | int ft_str_is_printable(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= 32 && str[i] <= 126) 9 | i++; 10 | else 11 | return (0); 12 | } 13 | return (1); 14 | } 15 | /* 16 | #include 17 | 18 | int main(void){ 19 | printf("%d\n", ft_str_is_printable("")); 20 | printf("%d\n", ft_str_is_printable("1b*A")); 21 | printf("%d\n", ft_str_is_printable("caña")); 22 | } 23 | */ 24 | -------------------------------------------------------------------------------- /42-piscine/C02/ex07/ft_strupcase.c: -------------------------------------------------------------------------------- 1 | char *ft_strupcase(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= 'a' && str[i] <= 'z') 9 | str[i] = str[i] - 32; 10 | i++; 11 | } 12 | return (str); 13 | } 14 | /* 15 | #include 16 | 17 | int main(void){ 18 | char str[] = "pru4Aba"; 19 | printf("%s", ft_strupcase(str)); 20 | } 21 | */ 22 | -------------------------------------------------------------------------------- /42-piscine/C02/ex08/ft_strlowcase.c: -------------------------------------------------------------------------------- 1 | char *ft_strlowcase(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | { 8 | if (str[i] >= 'A' && str[i] <= 'Z') 9 | str[i] = str[i] + 32; 10 | i++; 11 | } 12 | return (str); 13 | } 14 | /* 15 | #include 16 | 17 | int main(void){ 18 | char str[] = "PRUEB4"; 19 | printf("%s", ft_strlowcase(str)); 20 | } 21 | */ 22 | -------------------------------------------------------------------------------- /42-piscine/C02/ex10/ft_strlcpy.c: -------------------------------------------------------------------------------- 1 | unsigned int ft_strlcpy(char *dest, char *src, unsigned int size) 2 | { 3 | unsigned int i; 4 | 5 | i = 0; 6 | while ((src[i] != '\0') && (i < size - 1)) 7 | { 8 | dest[i] = src[i]; 9 | i++; 10 | } 11 | dest[i] = '\0'; 12 | while (src[i] != '\0') 13 | i++; 14 | return (i); 15 | } 16 | /* 17 | #include 18 | #include 19 | 20 | int main(void){ 21 | char dest[5]; 22 | char src[] = "Hola que tal"; 23 | printf("%d %s\n", strlcpy(dest, src, sizeof(dest)), dest); 24 | printf("%d %s\n", ft_strlcpy(dest, src, sizeof(dest)), dest); 25 | return (0); 26 | } 27 | */ 28 | -------------------------------------------------------------------------------- /42-piscine/C02/ex11/ft_putstr_non_printable.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | 8 | void ft_putstr_non_printable(char *str) 9 | { 10 | int i; 11 | 12 | i = 0; 13 | while (str[i] != '\0') 14 | { 15 | if (str[i] >= 32 && str[i] <= 126) 16 | ft_putchar(str[i]); 17 | else 18 | { 19 | ft_putchar('\\'); 20 | ft_putchar("0123456789abcdef"[str[i] / 16]); 21 | ft_putchar("0123456789abcdef"[str[i] % 16]); 22 | } 23 | i++; 24 | } 25 | } 26 | /* 27 | int main(void){ 28 | ft_putstr_non_printable("Prueba\tdel ejer\nrcicio 11"); 29 | ft_putchar('\n'); 30 | ft_putstr_non_printable("Coucou\ntu vas bien ?"); 31 | } 32 | */ 33 | -------------------------------------------------------------------------------- /42-piscine/C03/ex00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | int ft_strcmp(char *s1, char *s2) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (s1[i] != '\0' || s2[i] != '\0') 7 | { 8 | if (s1[i] < s2[i]) 9 | return (-1); 10 | else if (s1[i] > s2[i]) 11 | return (1); 12 | i++; 13 | } 14 | return (0); 15 | } 16 | /* 17 | #include 18 | #include 19 | 20 | int main(void){ 21 | printf("%d\n", ft_strcmp("test", "test")); 22 | printf("%d\n", strcmp("test", "test")); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /42-piscine/C03/ex01/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | int ft_strncmp(char *s1, char *s2, unsigned int n) 2 | { 3 | unsigned int i; 4 | 5 | i = 0; 6 | while ((s1[i] != '\0' || s2[i] != '\0') && i < n) 7 | { 8 | if (s1[i] < s2[i]) 9 | return (-1); 10 | else if (s1[i] > s2[i]) 11 | return (1); 12 | i++; 13 | } 14 | return (0); 15 | } 16 | /* 17 | #include 18 | #include 19 | 20 | int main(void){ 21 | printf("%d\n", ft_strncmp("hola que tal", "hola mundo", 4)); 22 | printf("%d\n", strncmp("hola que tal", "hola mundo", 4)); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /42-piscine/C03/ex02/ft_strcat.c: -------------------------------------------------------------------------------- 1 | char *ft_strcat(char *dest, char *src) 2 | { 3 | int i; 4 | int j; 5 | 6 | i = 0; 7 | j = 0; 8 | while (dest[i] != '\0') 9 | i++; 10 | while (src[j] != '\0') 11 | { 12 | dest[i] = src[j]; 13 | i++; 14 | j++; 15 | } 16 | dest[i] = '\0'; 17 | return (dest); 18 | } 19 | /* 20 | #include 21 | #include 22 | 23 | int main(void){ 24 | char dest[11] = "Hola "; 25 | char src[] = "mundo"; 26 | //printf("%s\n", ft_strcat(dest, src)); 27 | printf("%s\n", strcat(dest, src)); 28 | } 29 | */ 30 | -------------------------------------------------------------------------------- /42-piscine/C03/ex03/ft_strncat.c: -------------------------------------------------------------------------------- 1 | char *ft_strncat(char *dest, char *src, unsigned int nb) 2 | { 3 | unsigned int i; 4 | unsigned int j; 5 | 6 | i = 0; 7 | j = 0; 8 | while (dest[i] != '\0') 9 | i++; 10 | while (src[j] != '\0' && j < nb) 11 | { 12 | dest[i + j] = src[j]; 13 | j++; 14 | } 15 | dest[i + j] = '\0'; 16 | return (dest); 17 | } 18 | /* 19 | #include 20 | #include 21 | 22 | int main(void){ 23 | char dest[20] = "hola "; 24 | char src[] = "que talBanana"; 25 | //printf("%s\n", strncat(dest, src, 7)); 26 | printf("%s\n", ft_strncat(dest, src, 7)); 27 | } 28 | */ 29 | -------------------------------------------------------------------------------- /42-piscine/C03/ex04/ft_strstr.c: -------------------------------------------------------------------------------- 1 | char *ft_strstr(char *str, char *to_find) 2 | { 3 | int i; 4 | int j; 5 | 6 | i = 0; 7 | j = 0; 8 | if (to_find[j] == '\0') 9 | return (str); 10 | while (str[i] != '\0') 11 | { 12 | while (str[i + j] == to_find[j] && str[i + j] != '\0') 13 | j++; 14 | if (to_find[j] == '\0') 15 | return (str + i); 16 | i++; 17 | j = 0; 18 | } 19 | return (0); 20 | } 21 | /* 22 | #include 23 | #include 24 | 25 | int main(void){ 26 | char str[] = "Prueba del ejercicio 4 del C03 y me cago en la molinette"; 27 | char find[] = "me"; 28 | printf("%s\n", ft_strstr(str, find)); 29 | printf("%s\n", strstr(str, find)); 30 | } 31 | */ 32 | -------------------------------------------------------------------------------- /42-piscine/C04/ex00/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i = 0; 6 | while (str[i] != '\0') 7 | i++; 8 | return (i); 9 | } 10 | /* 11 | #include 12 | 13 | int main(void){ 14 | printf("%d", ft_strlen("Hello World")); 15 | } 16 | */ 17 | -------------------------------------------------------------------------------- /42-piscine/C04/ex01/ft_putstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putstr(char *str) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | write(1, &str[i], 1); 11 | i++; 12 | } 13 | } 14 | /* 15 | int main(void){ 16 | ft_putstr("Hello World"); 17 | return (0); 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /42-piscine/C04/ex02/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | 8 | void ft_putnbr(int nb) 9 | { 10 | long n; 11 | 12 | n = nb; 13 | if (n < 0) 14 | { 15 | ft_putchar('-'); 16 | n = -n; 17 | } 18 | if (n > 9) 19 | { 20 | ft_putnbr(n / 10); 21 | ft_putnbr(n % 10); 22 | } 23 | else 24 | ft_putchar(n + '0'); 25 | } 26 | /* 27 | int main(void){ 28 | ft_putnbr(-2147483648); 29 | } 30 | */ 31 | -------------------------------------------------------------------------------- /42-piscine/C04/ex03/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(char *str) 2 | { 3 | int i; 4 | int sig; 5 | int result; 6 | 7 | i = 0; 8 | sig = 1; 9 | result = 0; 10 | while (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r')) 11 | i++; 12 | while (str[i] == '-' || str[i] == '+') 13 | { 14 | if (str[i] == '-') 15 | sig = -sig; 16 | i++; 17 | } 18 | while (str[i] >= '0' && str[i] <= '9') 19 | { 20 | result = (str[i] - '0') + (result * 10); 21 | i++; 22 | } 23 | return (result * sig); 24 | } 25 | /* 26 | #include 27 | 28 | int main(void){ 29 | printf("%d\n", ft_atoi(" ---+--+1234ab567")); 30 | } 31 | */ 32 | -------------------------------------------------------------------------------- /42-piscine/C06/ex00/ft_print_program_name.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (argc && argv[0][i] != '\0') 9 | { 10 | write(1, &argv[0][i], 1); 11 | i++; 12 | } 13 | write(1, "\n", 1); 14 | return (0); 15 | } 16 | -------------------------------------------------------------------------------- /42-piscine/C06/ex01/ft_print_params.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int i; 6 | int j; 7 | 8 | j = 1; 9 | while (j < argc) 10 | { 11 | i = 0; 12 | while (argv[j][i]) 13 | { 14 | write(1, &argv[j][i], 1); 15 | i++; 16 | } 17 | write(1, "\n", 1); 18 | j++; 19 | } 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /42-piscine/C06/ex02/ft_rev_params.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int i; 6 | int j; 7 | 8 | j = argc - 1; 9 | while (j > 0) 10 | { 11 | i = 0; 12 | while (argc && argv[j][i] != '\0') 13 | { 14 | write(1, &argv[j][i], 1); 15 | i++; 16 | } 17 | write(1, "\n", 1); 18 | j--; 19 | } 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /42-piscine/Rush00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | -------------------------------------------------------------------------------- /42-piscine/Rush00/ex00/main.c: -------------------------------------------------------------------------------- 1 | void rush(int x, int y); 2 | 3 | int main(void) 4 | { 5 | rush(7, 6); 6 | return (0); 7 | } 8 | -------------------------------------------------------------------------------- /42-piscine/Rush00/ex00/rush00.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void rush(int x, int y) 4 | { 5 | int column; 6 | int row; 7 | 8 | if (x < 0 || y < 0) 9 | return ; 10 | column = 1; 11 | row = 1; 12 | while (row <= y) 13 | { 14 | while (column <= x) 15 | { 16 | if ((row == 1 || row == y) && (column == 1 || column == x)) 17 | ft_putchar('o'); 18 | else if (row == 1 || row == y) 19 | ft_putchar('-'); 20 | else if (column == 1 || column == x) 21 | ft_putchar('|'); 22 | else 23 | ft_putchar(' '); 24 | column++; 25 | } 26 | row++; 27 | column = 1; 28 | ft_putchar('\n'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex00/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex03/id_rsa_pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5+o3J+cHrltZm8lpye/sClMcl0R4Wwydnnpb5Bw2mqQWJAdJkaUnBMfGEc4iWEcee9aUgnsscq09usKv2w6sLftA7EVkSeySHUvZNGdhjtO+9ajcbP2TFuilsQbwyrTbkAeBOcg7dExZVW9IhIm6Qyqpp57AjgO/b0QQUSYCLKLi5wzRBYnHpXH9hbLJX9v0FJOJCbNSo5BnQnsv3NhhCPAo0L+5ujnBtF4e+MZb4wSvQRYsF4q6PBQuV8PSkIbAaz9JssQZrG9vIcodZEHpZUTSJ4d5lIv567fi32EnrmInN0JEW260PogJbX4MG7jW61b1QVxbMXFtEY+h2f9cf8kpNNiLzZGYwwM32CtavPCG7nzfCaemt2TlHmKghg5qIOq5G85qSm1w+tl+75KEGDrNd1bugPXtx+HcNdPqy8ayXUYqAA1TG9T1I9pXR/4W8q9CNQZNiuEJC6ledgX9qBsXDh7J952FUVBhvBF2xChDIO7f6CWbH8gbYnqYTQks= ezafra-r@c1r6s2.42malaga.com 2 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex04/midLS: -------------------------------------------------------------------------------- 1 | ls -mtp 2 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex05/git_commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # "git log" para enseñarnos el historial de commits que hayamos realizado 3 | # "-5" nos enseña los ultimos 5 commits 4 | # "--pretty=%H" para capturar solamente al id (hash) de nuestro commit 5 | git log -5 --pretty=%H 6 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex06/git_ignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git ls-files -o -i --exclude-standard 3 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex07/b: -------------------------------------------------------------------------------- 1 | Episode V, A NEW H0PE It is a period of civil war 2 | Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. 3 | During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the STAR DEATH, an armored space station with enough power to destroy an entire planet. 4 | 5 | 6 | Pursued by the Empire's sinister agents, 7 | Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie.. 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex08/clean: -------------------------------------------------------------------------------- 1 | find . -type f \( -iname "*~" -or -iname "#*#" \) -print -delete 2 | -------------------------------------------------------------------------------- /42-piscine/Shell00/ex09/ft_magic: -------------------------------------------------------------------------------- 1 | 41 string 42 42 file 2 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex01/print_groups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | groups $FT_USER | tr ' ' ',' | tr -d '\n' 3 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex02/find_sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f -name '*.sh' -exec basename {} .sh \; 3 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . \( -type f -or -type d \) | wc -l | awk '{print $1}' 3 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex04/MAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ifconfig | grep "ether " | awk '{print $2}' 3 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex05/"\?$*'MaRViN'*$?\": -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /42-piscine/Shell01/ex06/skip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -l | sed -n 'p;n' 3 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex07/r_dwssap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat /etc/passwd | grep \# -v | sed -n 'n;p' | cut -d ':' -f 1 | rev | sort -r | awk "NR>=$FT_LINE1 && NR<=$FT_LINE2" | tr '\n' ',' | sed 's:,:, :g;s:, $:.:' | tr -d '\n' 3 | 4 | -------------------------------------------------------------------------------- /42-piscine/Shell01/ex08/add_chelou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "obase=13;ibase=5;" $FT_NBR1+$FT_NBR2 | tr "\'" '0' | tr '\\\"\?\!mrdoc' "123401234" | sed 's/3/o/' | bc | tr '0123456789ABC' 'gtaio\ luSnemf' 3 | -------------------------------------------------------------------------------- /public/42-malaga-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/public/42-malaga-logo.jpg -------------------------------------------------------------------------------- /public/common_core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/public/common_core.png -------------------------------------------------------------------------------- /public/discover_web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/public/discover_web.png -------------------------------------------------------------------------------- /public/es_norm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/public/es_norm.pdf -------------------------------------------------------------------------------- /public/piscine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zafraedu/42-Projects/3bb1419fef0af2767275149432a5ffa58fc52896/public/piscine.png --------------------------------------------------------------------------------