!git clone https://github.com/magnitopic/push_swap.git
Cloning into 'push_swap'... remote: Enumerating objects: 876, done. remote: Counting objects: 100% (265/265), done. remote: Compressing objects: 100% (169/169), done. remote: Total 876 (delta 184), reused 170 (delta 92), pack-reused 611 Receiving objects: 100% (876/876), 121.37 KiB | 2.38 MiB/s, done. Resolving deltas: 100% (526/526), done.
%cd push_swap
/content/push_swap
!pwd
/content/push_swap
!git submodule init
!git submodule update
!make
Submodule 'libft' (https://github.com/magnitopic/libft.git) registered for path 'libft' Cloning into '/content/push_swap/libft'... Submodule path 'libft': checked out '6f7ebe398e095c780d6a142f69d3243cde40892f' make[1]: Entering directory '/content/push_swap/libft' gcc -Wall -Wextra -Werror -c -o ft_isalnum.o ft_isalnum.c gcc -Wall -Wextra -Werror -c -o ft_isprint.o ft_isprint.c gcc -Wall -Wextra -Werror -c -o ft_memcmp.o ft_memcmp.c gcc -Wall -Wextra -Werror -c -o ft_putchar_fd.o ft_putchar_fd.c gcc -Wall -Wextra -Werror -c -o ft_strlcat.o ft_strlcat.c gcc -Wall -Wextra -Werror -c -o ft_strncmp.o ft_strncmp.c gcc -Wall -Wextra -Werror -c -o ft_substr.o ft_substr.c gcc -Wall -Wextra -Werror -c -o ft_atoi.o ft_atoi.c gcc -Wall -Wextra -Werror -c -o ft_isalpha.o ft_isalpha.c gcc -Wall -Wextra -Werror -c -o ft_itoa.o ft_itoa.c gcc -Wall -Wextra -Werror -c -o ft_memcpy.o ft_memcpy.c gcc -Wall -Wextra -Werror -c -o ft_putendl_fd.o ft_putendl_fd.c gcc -Wall -Wextra -Werror -c -o ft_strchr.o ft_strchr.c gcc -Wall -Wextra -Werror -c -o ft_strlcpy.o ft_strlcpy.c gcc -Wall -Wextra -Werror -c -o ft_strnstr.o ft_strnstr.c gcc -Wall -Wextra -Werror -c -o ft_tolower.o ft_tolower.c gcc -Wall -Wextra -Werror -c -o ft_bzero.o ft_bzero.c gcc -Wall -Wextra -Werror -c -o ft_isascii.o ft_isascii.c gcc -Wall -Wextra -Werror -c -o ft_split.o ft_split.c gcc -Wall -Wextra -Werror -c -o ft_memmove.o ft_memmove.c gcc -Wall -Wextra -Werror -c -o ft_putnbr_fd.o ft_putnbr_fd.c gcc -Wall -Wextra -Werror -c -o ft_strdup.o ft_strdup.c gcc -Wall -Wextra -Werror -c -o ft_strlen.o ft_strlen.c gcc -Wall -Wextra -Werror -c -o ft_strrchr.o ft_strrchr.c gcc -Wall -Wextra -Werror -c -o ft_toupper.o ft_toupper.c gcc -Wall -Wextra -Werror -c -o ft_calloc.o ft_calloc.c gcc -Wall -Wextra -Werror -c -o ft_isdigit.o ft_isdigit.c gcc -Wall -Wextra -Werror -c -o ft_memchr.o ft_memchr.c gcc -Wall -Wextra -Werror -c -o ft_memset.o ft_memset.c gcc -Wall -Wextra -Werror -c -o ft_putstr_fd.o ft_putstr_fd.c gcc -Wall -Wextra -Werror -c -o ft_strjoin.o ft_strjoin.c gcc -Wall -Wextra -Werror -c -o ft_strmapi.o ft_strmapi.c gcc -Wall -Wextra -Werror -c -o ft_strtrim.o ft_strtrim.c gcc -Wall -Wextra -Werror -c -o ft_fstrjoin.o ft_fstrjoin.c gcc -Wall -Wextra -Werror -c -o ft_striteri.o ft_striteri.c gcc -Wall -Wextra -Werror -c -o ft_printf.o ft_printf.c gcc -Wall -Wextra -Werror -c -o ft_printalpha.o ft_printalpha.c gcc -Wall -Wextra -Werror -c -o ft_printnum.o ft_printnum.c gcc -Wall -Wextra -Werror -c -o get_next_line.o get_next_line.c gcc -Wall -Wextra -Werror -c -o get_next_line_utils.o get_next_line_utils.c gcc -Wall -Wextra -Werror -c -o math/ft_abs.o math/ft_abs.c ==> Libft compiled ✅ gcc -Wall -Wextra -Werror -c -o lists/ft_lstnew.o lists/ft_lstnew.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_front.o lists/ft_lstadd_front.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstsize.o lists/ft_lstsize.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstcompare.o lists/ft_lstcompare.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstlast.o lists/ft_lstlast.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_back.o lists/ft_lstadd_back.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstdelone.o lists/ft_lstdelone.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstclear.o lists/ft_lstclear.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstiter.o lists/ft_lstiter.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstmap.o lists/ft_lstmap.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_int.o lists/ft_lstprint_int.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_char.o lists/ft_lstprint_char.c gcc -Wall -Wextra -Werror -c -o lists/ft_get.o lists/ft_get.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstmin.o lists/ft_lstmin.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstcpy.o lists/ft_lstcpy.c ==> Libft bonus compiled ✅✨ make[1]: Leaving directory '/content/push_swap/libft' gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/stack.o src/stack.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/stack2.o src/stack2.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/helpers.o src/helpers.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/push_swap.o src/push_swap.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/validator.o src/validator.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/dictionary.o src/dictionary.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/short_sort.o src/short_sort.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/modern_times.o src/modern_times.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_push.o src/moves/ft_push.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/modern_times2.o src/modern_times2.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_swap.o src/moves/ft_swap.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_rotate.o src/moves/ft_rotate.c gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_reverse_rotate.o src/moves/ft_reverse_rotate.c ==> Push_swap compiled ✅
!make re
==> Removed Push_swap 🗑️ make[1]: Entering directory '/content/push_swap/libft' ==> Removed Libft 🗑️ make[1]: Leaving directory '/content/push_swap/libft' make[1]: Entering directory '/content/push_swap/libft' gcc -Wall -Wextra -Werror -c -o ft_isalnum.o ft_isalnum.c gcc -Wall -Wextra -Werror -c -o ft_isprint.o ft_isprint.c gcc -Wall -Wextra -Werror -c -o ft_memcmp.o ft_memcmp.c gcc -Wall -Wextra -Werror -c -o ft_putchar_fd.o ft_putchar_fd.c gcc -Wall -Wextra -Werror -c -o ft_strlcat.o ft_strlcat.c gcc -Wall -Wextra -Werror -c -o ft_strncmp.o ft_strncmp.c gcc -Wall -Wextra -Werror -c -o ft_substr.o ft_substr.c gcc -Wall -Wextra -Werror -c -o ft_atoi.o ft_atoi.c gcc -Wall -Wextra -Werror -c -o ft_isalpha.o ft_isalpha.c gcc -Wall -Wextra -Werror -c -o ft_itoa.o ft_itoa.c gcc -Wall -Wextra -Werror -c -o ft_memcpy.o ft_memcpy.c gcc -Wall -Wextra -Werror -c -o ft_putendl_fd.o ft_putendl_fd.c gcc -Wall -Wextra -Werror -c -o ft_strchr.o ft_strchr.c gcc -Wall -Wextra -Werror -c -o ft_strlcpy.o ft_strlcpy.c gcc -Wall -Wextra -Werror -c -o ft_strnstr.o ft_strnstr.c gcc -Wall -Wextra -Werror -c -o ft_tolower.o ft_tolower.c gcc -Wall -Wextra -Werror -c -o ft_bzero.o ft_bzero.c gcc -Wall -Wextra -Werror -c -o ft_isascii.o ft_isascii.c gcc -Wall -Wextra -Werror -c -o ft_split.o ft_split.c gcc -Wall -Wextra -Werror -c -o ft_memmove.o ft_memmove.c gcc -Wall -Wextra -Werror -c -o ft_putnbr_fd.o ft_putnbr_fd.c gcc -Wall -Wextra -Werror -c -o ft_strdup.o ft_strdup.c gcc -Wall -Wextra -Werror -c -o ft_strlen.o ft_strlen.c gcc -Wall -Wextra -Werror -c -o ft_strrchr.o ft_strrchr.c gcc -Wall -Wextra -Werror -c -o ft_toupper.o ft_toupper.c gcc -Wall -Wextra -Werror -c -o ft_calloc.o ft_calloc.c gcc -Wall -Wextra -Werror -c -o ft_isdigit.o ft_isdigit.c gcc -Wall -Wextra -Werror -c -o ft_memchr.o ft_memchr.c gcc -Wall -Wextra -Werror -c -o ft_memset.o ft_memset.c gcc -Wall -Wextra -Werror -c -o ft_putstr_fd.o ft_putstr_fd.c gcc -Wall -Wextra -Werror -c -o ft_strjoin.o ft_strjoin.c gcc -Wall -Wextra -Werror -c -o ft_strmapi.o ft_strmapi.c gcc -Wall -Wextra -Werror -c -o ft_strtrim.o ft_strtrim.c gcc -Wall -Wextra -Werror -c -o ft_fstrjoin.o ft_fstrjoin.c gcc -Wall -Wextra -Werror -c -o ft_striteri.o ft_striteri.c gcc -Wall -Wextra -Werror -c -o ft_printf.o ft_printf.c gcc -Wall -Wextra -Werror -c -o ft_printalpha.o ft_printalpha.c gcc -Wall -Wextra -Werror -c -o ft_printnum.o ft_printnum.c gcc -Wall -Wextra -Werror -c -o get_next_line.o get_next_line.c gcc -Wall -Wextra -Werror -c -o get_next_line_utils.o get_next_line_utils.c gcc -Wall -Wextra -Werror -c -o math/ft_abs.o math/ft_abs.c ==> Libft compiled ✅ gcc -Wall -Wextra -Werror -c -o lists/ft_lstnew.o lists/ft_lstnew.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_front.o lists/ft_lstadd_front.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstsize.o lists/ft_lstsize.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstcompare.o lists/ft_lstcompare.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstlast.o lists/ft_lstlast.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_back.o lists/ft_lstadd_back.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstdelone.o lists/ft_lstdelone.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstclear.o lists/ft_lstclear.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstiter.o lists/ft_lstiter.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstmap.o lists/ft_lstmap.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_int.o lists/ft_lstprint_int.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_char.o lists/ft_lstprint_char.c gcc -Wall -Wextra -Werror -c -o lists/ft_get.o lists/ft_get.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstmin.o lists/ft_lstmin.c gcc -Wall -Wextra -Werror -c -o lists/ft_lstcpy.o lists/ft_lstcpy.c ==> Libft bonus compiled ✅✨ make[1]: Leaving directory '/content/push_swap/libft' gcc -Wall -Werror -Wextra -c -o src/stack.o src/stack.c gcc -Wall -Werror -Wextra -c -o src/stack2.o src/stack2.c gcc -Wall -Werror -Wextra -c -o src/helpers.o src/helpers.c gcc -Wall -Werror -Wextra -c -o src/push_swap.o src/push_swap.c gcc -Wall -Werror -Wextra -c -o src/validator.o src/validator.c gcc -Wall -Werror -Wextra -c -o src/dictionary.o src/dictionary.c gcc -Wall -Werror -Wextra -c -o src/short_sort.o src/short_sort.c gcc -Wall -Werror -Wextra -c -o src/modern_times.o src/modern_times.c gcc -Wall -Werror -Wextra -c -o src/moves/ft_push.o src/moves/ft_push.c gcc -Wall -Werror -Wextra -c -o src/modern_times2.o src/modern_times2.c gcc -Wall -Werror -Wextra -c -o src/moves/ft_swap.o src/moves/ft_swap.c gcc -Wall -Werror -Wextra -c -o src/moves/ft_rotate.o src/moves/ft_rotate.c gcc -Wall -Werror -Wextra -c -o src/moves/ft_reverse_rotate.o src/moves/ft_reverse_rotate.c ==> Push_swap compiled ✅ ==> Push_swap recompiled 🔄
!./push_swap 4 3 2 1 5 | wc -l
8
# subir el archivo checker_linux a /content/push_swap
!chmod 777 checker_linux
!./push_swap 4 3 2 1 5 | ./checker_linux 4 3 2 1 5
OK
!NUM="0 67 -10 87 5"; ./push_swap $NUM | wc -l && ./push_swap $NUM | ./checker_linux $NUM
6 OK
!NUM="4 67 3 87 23"; ./push_swap $NUM
pb sa pb rrr pa pa
!NUM="4 67 3 87 23"; PASOS=$(./push_swap $NUM); echo $PASOS
pb sa pb rrr pa pa
# El resultado del push_swap con los pasos se mete en una variable para no tenerlo que invocar dos veces
!NUM="4 67 3 87 23"; PASOS=$(./push_swap $NUM); echo "$PASOS" | wc -l && echo "$PASOS" | ./checker_linux $NUM
6 OK
# Llevamos el resultado a archivo text.txt
!NUM="4 67 3 87 23"; echo "$NUM" >> test.txt; PASOS=$(./push_swap $NUM); echo "$PASOS" | wc -l >> test.txt && echo "$PASOS" | ./checker_linux $NUM >> test.txt
from random import seed, shuffle
seed()
n = 9 # número de elementos de la pila
a = list(range(1, n+1)); shuffle(a) # generación aleatoria de la pila A
a_str = ' '.join(map(str, a)) # convertimos la lista en un string de números separados por espacios
print(a_str)
3 4 1 6 5 8 2 7 9
f = open("numero.txt", "w") # crea un archivo vacío si no existe. Si ya existe no da error
f.write(a_str)
f.close()
!NUM=$(<numero.txt); echo "$NUM"
3 4 1 6 5 8 2 7 9
!NUM=$(<numero.txt); echo "$NUM" >> test.txt; PASOS=$(./push_swap $NUM); echo "$PASOS" | wc -l >> test.txt && echo "$PASOS" | ./checker_linux $NUM >> test.txt
from random import seed, shuffle
from google.colab import files
seed()
n = 500 # número de elementos de la pila
for i in range(95):
a = list(range(1, n+1)); shuffle(a) # generación aleatoria de la pila A
a_str = ' '.join(map(str, a))
#print(a_str, "\n")
f = open("numero.txt", "w") # crea un archivo vacío si no existe. Si ya existe no da error
f.write(a_str)
f.close()
!NUM=$(<numero.txt); echo "$NUM" >> test.txt; PASOS=$(./push_swap $NUM); echo "$PASOS" | wc -l >> test.txt && echo "$PASOS" | ./checker_linux $NUM >> test.txt
files.download('test.txt')