{"id":21933172,"url":"https://github.com/link-wolf/push_swap","last_synced_at":"2026-05-03T13:40:30.053Z","repository":{"id":47124388,"uuid":"470879038","full_name":"Link-Wolf/push_swap","owner":"Link-Wolf","description":"42 project - Program to sort stacks with only a few operation in an optimal way","archived":false,"fork":false,"pushed_at":"2024-10-01T14:28:15.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-27T12:49:41.959Z","etag":null,"topics":["42","42born2code","42school","c","macos"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Link-Wolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T06:48:41.000Z","updated_at":"2024-10-01T14:29:33.000Z","dependencies_parsed_at":"2025-01-27T12:54:32.855Z","dependency_job_id":null,"html_url":"https://github.com/Link-Wolf/push_swap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Link-Wolf%2Fpush_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Link-Wolf%2Fpush_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Link-Wolf%2Fpush_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Link-Wolf%2Fpush_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Link-Wolf","download_url":"https://codeload.github.com/Link-Wolf/push_swap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244960985,"owners_count":20538911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42born2code","42school","c","macos"],"created_at":"2024-11-29T00:08:43.686Z","updated_at":"2026-05-03T13:40:25.007Z","avatar_url":"https://github.com/Link-Wolf.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/Link-Wolf/push_swap\" title=\"Go to GitHub repo\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=Link-Wolf\u0026message=push_swap\u0026color=blue\u0026logo=github\u0026style=for-the-badge\" alt=\"Link-Wolf - push_swap\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://\"\u003e\u003cimg src=\"https://img.shields.io/badge/42_grade-121_%2F_100-brightgreen?style=for-the-badge\" alt=\"42 grade - 121 / 100\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://\"\u003e\u003cimg src=\"https://img.shields.io/badge/Year-2022-ffad9b?style=for-the-badge\" alt=\"Year - 2022\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/Link-Wolf/push_swap/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/Link-Wolf/push_swap?style=for-the-badge\u0026color=yellow\" alt=\"stars - push_swap\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/Link-Wolf/push_swap/network/members\"\u003e\u003cimg src=\"https://img.shields.io/github/forks/Link-Wolf/push_swap?style=for-the-badge\u0026color=lightgray\" alt=\"forks - push_swap\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/Link-Wolf/push_swap/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/Link-Wolf/push_swap?style=for-the-badge\u0026color=orange\" alt=\"issues - push_swap\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://www.apple.com/macos/\" title=\"Go to Apple homepage\"\u003e\u003cimg src=\"https://img.shields.io/badge/OS-macOS-blue?logo=apple\u0026logoColor=white\u0026style=for-the-badge\u0026color=9cf\" alt=\"OS - macOS\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca\u003e\n    \u003cimg src=\"https://www.42mulhouse.fr/wp-content/uploads/2022/06/logo-42-Mulhouse-white.svg\" alt=\"Logo\" width=\"192\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n  \u003ch3 align=\"center\"\u003ePush_swap\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n\t  \u003cem\u003eBecause Swap_push isn’t as natural\u003c/em\u003e\u003cbr/\u003e\n    Optimized data sorting on stacks\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/Link-Wolf/push_swap/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/Link-Wolf/push_swap/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\n\u003cdiv\u003e\n\u003cp\u003e\n  \u003ca\u003e\n    \u003cimg src=\"assets/push_swap.webp\" alt=\"push_swap illustration\"\u003e\n  \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\nThis project is a very simple and highly effective algorithm project: data will\nneed to be sorted. \u003c/br\u003e\nWe have at our disposal, 2 stacks (`a` and `b`), a set of int values without duplicates that will be initialized in the stack `a`, and a set of instructions to manipulate both stacks :\n\n-   `ra` / `rb` rotates either `a` or `b`\n-   `rra` / `rrb` rotates either `a` or `b` but in the other direction\n-   `rr` / `rrr` rotates both `a` and `b` in one direction or the other\n-   `pa` pushes the top element of `b` to `a`\n-   `pb` pushes the top element of `a` to `b`\n-   `sa` / `sb` switches the two top elements of `a` / `b`\n-   `ss` switches the two top elements of both `a` and `b`\n\nThe program should then print in the terminal all the instructions to sort the int values into the stack `a`, by using the stack `b`\n\nThe evaluation is made according to the performance of the program (how many operations the program print to sort the stack `a`)\n\n### Bonus features\n\nMake a \"Checker\" which will get as an argument the stack `a` formatted as a list of integers (in the same way as the push_swap program)\n\nThe program will then wait and read instructions on the standard input.\nOnce all the instructions have been read, the checker will execute them on the stack received as an argument and print `OK` only if the stack `a` is correctly sorted, `KO` otherwise.\n\nWe can call the push_swap program then pipe `|` the checker with the same arguments to verify if our push_swap works as intended\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting Started\n\nBecause it's a simple C program, there isn't much to say here\n\n### Prerequisites\n\nHaving a C compiler like cc, gcc or clang\n\n### Installation\n\n1. Clone the repo\n    ```sh\n    git clone https://github.com/Link-Wolf/push_swap.git\n    ```\n2. Compile push_swap\n    ```sh\n    cd push_swap; make\n    ```\n3. Execute the program with a list of integers as a parameter / multiples parameters\n    ```sh\n    ./push_swap \"5 648 1 36 -1 98 -364 0\"\n    ```\n    or\n    ```sh\n    ./push_swap 5 648 1 36 -1 98 -364 0\n    ```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n## Usage\n\nTest this push_swap with the integers you want, and with as many you want !\n\n#### Push swap program\n\n```sh\n   ./push_swap \"5 1 -1 -3 0\"\n```\n\n#### Possible output\n\n```\n\tpb\n\tpb\n\tsa\n\tpa\n\tra\n\tpa\n\tra\n```\n\n#### Checker program\n\n```sh\n   ./push_swap \"5 1 -1 -3 0\" | ./checker \"5 1 -1 -3 0\"\n```\n\n#### Output\n\n```\n\tOK\n```\n\n_The checker will print `Error` if one of the given instructions does not exist_\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ROADMAP --\u003e\n\n## Roadmap\n\n-   [x] Add the checker\n-   [x] Add back to top links\n\nSee the [open issues](https://github.com/Link-Wolf/push_swap/issues) for a full list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-wolf%2Fpush_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flink-wolf%2Fpush_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-wolf%2Fpush_swap/lists"}