{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyP4avIgE341BFsGzwo0pe22",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"id": "Z9u0X2_GvRB1",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "125a4ca2-ec4d-43bf-94d3-f8426f9a6b24"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'push_swap'...\n",
"remote: Enumerating objects: 876, done.\u001b[K\n",
"remote: Counting objects: 100% (265/265), done.\u001b[K\n",
"remote: Compressing objects: 100% (169/169), done.\u001b[K\n",
"remote: Total 876 (delta 184), reused 170 (delta 92), pack-reused 611\u001b[K\n",
"Receiving objects: 100% (876/876), 121.37 KiB | 2.38 MiB/s, done.\n",
"Resolving deltas: 100% (526/526), done.\n"
]
}
],
"source": [
"!git clone https://github.com/magnitopic/push_swap.git"
]
},
{
"cell_type": "code",
"source": [
"%cd push_swap"
],
"metadata": {
"id": "y1Wf-AjdvsQG",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "ca6cb6ab-9414-4fdd-9f4b-eca104ad0545"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/push_swap\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!pwd"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "KiI-5y33D_Z7",
"outputId": "d613df64-4124-488e-84b4-9f83fa4e80ef"
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/push_swap\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git submodule init\n",
"!git submodule update\n",
"!make"
],
"metadata": {
"id": "BNcoGudDvYhl",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "b3576914-7e68-459e-98e6-507090f8dbd6"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Submodule 'libft' (https://github.com/magnitopic/libft.git) registered for path 'libft'\n",
"Cloning into '/content/push_swap/libft'...\n",
"Submodule path 'libft': checked out '6f7ebe398e095c780d6a142f69d3243cde40892f'\n",
"make[1]: Entering directory '/content/push_swap/libft'\n",
"gcc -Wall -Wextra -Werror -c -o ft_isalnum.o ft_isalnum.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isprint.o ft_isprint.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memcmp.o ft_memcmp.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putchar_fd.o ft_putchar_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlcat.o ft_strlcat.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strncmp.o ft_strncmp.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_substr.o ft_substr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_atoi.o ft_atoi.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isalpha.o ft_isalpha.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_itoa.o ft_itoa.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memcpy.o ft_memcpy.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putendl_fd.o ft_putendl_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strchr.o ft_strchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlcpy.o ft_strlcpy.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strnstr.o ft_strnstr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_tolower.o ft_tolower.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_bzero.o ft_bzero.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isascii.o ft_isascii.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_split.o ft_split.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memmove.o ft_memmove.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putnbr_fd.o ft_putnbr_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strdup.o ft_strdup.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlen.o ft_strlen.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strrchr.o ft_strrchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_toupper.o ft_toupper.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_calloc.o ft_calloc.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isdigit.o ft_isdigit.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memchr.o ft_memchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memset.o ft_memset.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putstr_fd.o ft_putstr_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strjoin.o ft_strjoin.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strmapi.o ft_strmapi.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strtrim.o ft_strtrim.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_fstrjoin.o ft_fstrjoin.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_striteri.o ft_striteri.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printf.o ft_printf.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printalpha.o ft_printalpha.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printnum.o ft_printnum.c\n",
"gcc -Wall -Wextra -Werror -c -o get_next_line.o get_next_line.c\n",
"gcc -Wall -Wextra -Werror -c -o get_next_line_utils.o get_next_line_utils.c\n",
"gcc -Wall -Wextra -Werror -c -o math/ft_abs.o math/ft_abs.c\n",
"\u001b[0;34m==> \u001b[0;36mLibft compiled ✅\n",
"\n",
"\u001b[0mgcc -Wall -Wextra -Werror -c -o lists/ft_lstnew.o lists/ft_lstnew.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_front.o lists/ft_lstadd_front.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstsize.o lists/ft_lstsize.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstcompare.o lists/ft_lstcompare.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstlast.o lists/ft_lstlast.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_back.o lists/ft_lstadd_back.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstdelone.o lists/ft_lstdelone.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstclear.o lists/ft_lstclear.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstiter.o lists/ft_lstiter.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstmap.o lists/ft_lstmap.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_int.o lists/ft_lstprint_int.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_char.o lists/ft_lstprint_char.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_get.o lists/ft_get.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstmin.o lists/ft_lstmin.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstcpy.o lists/ft_lstcpy.c\n",
"\u001b[0;34m==> \u001b[0;36mLibft bonus compiled ✅✨\n",
"\n",
"\u001b[0mmake[1]: Leaving directory '/content/push_swap/libft'\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/stack.o src/stack.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/stack2.o src/stack2.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/helpers.o src/helpers.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/push_swap.o src/push_swap.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/validator.o src/validator.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/dictionary.o src/dictionary.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/short_sort.o src/short_sort.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/modern_times.o src/modern_times.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_push.o src/moves/ft_push.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/modern_times2.o src/modern_times2.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_swap.o src/moves/ft_swap.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_rotate.o src/moves/ft_rotate.c\n",
"gcc -Wall -Werror -Wextra -g3 -fsanitize=address -c -o src/moves/ft_reverse_rotate.o src/moves/ft_reverse_rotate.c\n",
"\u001b[0;34m==> \u001b[0;36mPush_swap compiled ✅\n",
"\n",
"\u001b[0m"
]
}
]
},
{
"cell_type": "code",
"source": [
"!make re"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "oE65ocOIq1UE",
"outputId": "85b6467d-0a32-4b45-ee84-b23a1f91d5c1"
},
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"\u001b[0;34m==> \u001b[0;31mRemoved Push_swap 🗑️\n",
"\u001b[0mmake[1]: Entering directory '/content/push_swap/libft'\n",
"\n",
"\u001b[0;34m==> \u001b[0;31mRemoved Libft 🗑️\n",
"\n",
"\u001b[0mmake[1]: Leaving directory '/content/push_swap/libft'\n",
"make[1]: Entering directory '/content/push_swap/libft'\n",
"gcc -Wall -Wextra -Werror -c -o ft_isalnum.o ft_isalnum.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isprint.o ft_isprint.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memcmp.o ft_memcmp.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putchar_fd.o ft_putchar_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlcat.o ft_strlcat.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strncmp.o ft_strncmp.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_substr.o ft_substr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_atoi.o ft_atoi.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isalpha.o ft_isalpha.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_itoa.o ft_itoa.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memcpy.o ft_memcpy.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putendl_fd.o ft_putendl_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strchr.o ft_strchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlcpy.o ft_strlcpy.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strnstr.o ft_strnstr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_tolower.o ft_tolower.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_bzero.o ft_bzero.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isascii.o ft_isascii.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_split.o ft_split.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memmove.o ft_memmove.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putnbr_fd.o ft_putnbr_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strdup.o ft_strdup.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strlen.o ft_strlen.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strrchr.o ft_strrchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_toupper.o ft_toupper.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_calloc.o ft_calloc.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_isdigit.o ft_isdigit.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memchr.o ft_memchr.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_memset.o ft_memset.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_putstr_fd.o ft_putstr_fd.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strjoin.o ft_strjoin.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strmapi.o ft_strmapi.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_strtrim.o ft_strtrim.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_fstrjoin.o ft_fstrjoin.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_striteri.o ft_striteri.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printf.o ft_printf.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printalpha.o ft_printalpha.c\n",
"gcc -Wall -Wextra -Werror -c -o ft_printnum.o ft_printnum.c\n",
"gcc -Wall -Wextra -Werror -c -o get_next_line.o get_next_line.c\n",
"gcc -Wall -Wextra -Werror -c -o get_next_line_utils.o get_next_line_utils.c\n",
"gcc -Wall -Wextra -Werror -c -o math/ft_abs.o math/ft_abs.c\n",
"\u001b[0;34m==> \u001b[0;36mLibft compiled ✅\n",
"\n",
"\u001b[0mgcc -Wall -Wextra -Werror -c -o lists/ft_lstnew.o lists/ft_lstnew.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_front.o lists/ft_lstadd_front.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstsize.o lists/ft_lstsize.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstcompare.o lists/ft_lstcompare.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstlast.o lists/ft_lstlast.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstadd_back.o lists/ft_lstadd_back.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstdelone.o lists/ft_lstdelone.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstclear.o lists/ft_lstclear.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstiter.o lists/ft_lstiter.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstmap.o lists/ft_lstmap.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_int.o lists/ft_lstprint_int.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstprint_char.o lists/ft_lstprint_char.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_get.o lists/ft_get.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstmin.o lists/ft_lstmin.c\n",
"gcc -Wall -Wextra -Werror -c -o lists/ft_lstcpy.o lists/ft_lstcpy.c\n",
"\u001b[0;34m==> \u001b[0;36mLibft bonus compiled ✅✨\n",
"\n",
"\u001b[0mmake[1]: Leaving directory '/content/push_swap/libft'\n",
"gcc -Wall -Werror -Wextra -c -o src/stack.o src/stack.c\n",
"gcc -Wall -Werror -Wextra -c -o src/stack2.o src/stack2.c\n",
"gcc -Wall -Werror -Wextra -c -o src/helpers.o src/helpers.c\n",
"gcc -Wall -Werror -Wextra -c -o src/push_swap.o src/push_swap.c\n",
"gcc -Wall -Werror -Wextra -c -o src/validator.o src/validator.c\n",
"gcc -Wall -Werror -Wextra -c -o src/dictionary.o src/dictionary.c\n",
"gcc -Wall -Werror -Wextra -c -o src/short_sort.o src/short_sort.c\n",
"gcc -Wall -Werror -Wextra -c -o src/modern_times.o src/modern_times.c\n",
"gcc -Wall -Werror -Wextra -c -o src/moves/ft_push.o src/moves/ft_push.c\n",
"gcc -Wall -Werror -Wextra -c -o src/modern_times2.o src/modern_times2.c\n",
"gcc -Wall -Werror -Wextra -c -o src/moves/ft_swap.o src/moves/ft_swap.c\n",
"gcc -Wall -Werror -Wextra -c -o src/moves/ft_rotate.o src/moves/ft_rotate.c\n",
"gcc -Wall -Werror -Wextra -c -o src/moves/ft_reverse_rotate.o src/moves/ft_reverse_rotate.c\n",
"\u001b[0;34m==> \u001b[0;36mPush_swap compiled ✅\n",
"\n",
"\u001b[0m\u001b[0;34m==> \u001b[0;36mPush_swap recompiled 🔄\n",
"\u001b[0m"
]
}
]
},
{
"cell_type": "code",
"source": [
"!./push_swap 4 3 2 1 5 | wc -l"
],
"metadata": {
"id": "8LY1MxtNp4RN",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "6e804036-ca0c-4b48-af14-e75c977d7da2"
},
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"8\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# subir el archivo checker_linux a /content/push_swap\n",
"!chmod 777 checker_linux"
],
"metadata": {
"id": "HmrQGp2nrFPo"
},
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!./push_swap 4 3 2 1 5 | ./checker_linux 4 3 2 1 5"
],
"metadata": {
"id": "4bUnKga7qUNw",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "e351d32f-ee85-46f7-9e85-1e2b2ec4ba1e"
},
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"OK\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!NUM=\"0 67 -10 87 5\"; ./push_swap $NUM | wc -l && ./push_swap $NUM | ./checker_linux $NUM"
],
"metadata": {
"id": "1ehmHsA0uJQL",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "c0d98103-8f2d-4e92-ee7b-5a0f9610569b"
},
"execution_count": 14,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"6\n",
"OK\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!NUM=\"4 67 3 87 23\"; ./push_swap $NUM"
],
"metadata": {
"id": "oj68_fa64qbv",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "fed8dd47-f6b1-4ed1-a307-07d339f3a34a"
},
"execution_count": 15,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"pb\n",
"sa\n",
"pb\n",
"rrr\n",
"pa\n",
"pa\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!NUM=\"4 67 3 87 23\"; PASOS=$(./push_swap $NUM); echo $PASOS"
],
"metadata": {
"id": "3e4fHwjawTzo",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "3f2b682a-20ca-4d5c-9cdd-aefd45cdf67e"
},
"execution_count": 16,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"pb sa pb rrr pa pa\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# El resultado del push_swap con los pasos se mete en una variable para no tenerlo que invocar dos veces\n",
"!NUM=\"4 67 3 87 23\"; PASOS=$(./push_swap $NUM); echo \"$PASOS\" | wc -l && echo \"$PASOS\" | ./checker_linux $NUM"
],
"metadata": {
"id": "Stnfa_HCwX5o",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "5f0216a9-c952-4418-e68d-8b3ca872e03a"
},
"execution_count": 17,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"6\n",
"OK\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Llevamos el resultado a archivo text.txt\n",
"!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"
],
"metadata": {
"id": "XjcQR3mr57t5"
},
"execution_count": 18,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from random import seed, shuffle\n",
"seed()\n",
"n = 9 # número de elementos de la pila\n",
"a = list(range(1, n+1)); shuffle(a) # generación aleatoria de la pila A\n",
"a_str = ' '.join(map(str, a)) # convertimos la lista en un string de números separados por espacios\n",
"print(a_str)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "wD2wzu8ZJS5h",
"outputId": "0071742b-4f2b-4d97-f16e-0b2c4c899e8f"
},
"execution_count": 19,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"3 4 1 6 5 8 2 7 9\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"f = open(\"numero.txt\", \"w\") # crea un archivo vacío si no existe. Si ya existe no da error\n",
"f.write(a_str)\n",
"f.close()"
],
"metadata": {
"id": "ejXsFipqMH0B"
},
"execution_count": 20,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!NUM=$(> test.txt; PASOS=$(./push_swap $NUM); echo \"$PASOS\" | wc -l >> test.txt && echo \"$PASOS\" | ./checker_linux $NUM >> test.txt"
],
"metadata": {
"id": "sdGkPkq7NaaS"
},
"execution_count": 22,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from random import seed, shuffle\n",
"from google.colab import files\n",
"seed()\n",
"n = 500 # número de elementos de la pila\n",
"\n",
"for i in range(95):\n",
" a = list(range(1, n+1)); shuffle(a) # generación aleatoria de la pila A\n",
" a_str = ' '.join(map(str, a))\n",
" #print(a_str, \"\\n\")\n",
" f = open(\"numero.txt\", \"w\") # crea un archivo vacío si no existe. Si ya existe no da error\n",
" f.write(a_str)\n",
" f.close()\n",
" !NUM=$(> test.txt; PASOS=$(./push_swap $NUM); echo \"$PASOS\" | wc -l >> test.txt && echo \"$PASOS\" | ./checker_linux $NUM >> test.txt\n",
"\n",
"files.download('test.txt')"
],
"metadata": {
"id": "TNbpiToOuE2J"
},
"execution_count": null,
"outputs": []
}
]
}