{"id":22503270,"url":"https://github.com/barimehdi77/push_swap","last_synced_at":"2025-10-27T13:11:46.498Z","repository":{"id":110027832,"uuid":"375080237","full_name":"barimehdi77/push_swap","owner":"barimehdi77","description":"This project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate various types of algorithms and choose the one (of many) most appropriate solution for an optimized data sorting","archived":false,"fork":false,"pushed_at":"2021-06-28T11:26:44.000Z","size":320,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T10:43:41.946Z","etag":null,"topics":["1337","42","42cursus","algo","c","checker","pushswap","sort-data"],"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/barimehdi77.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":"2021-06-08T16:44:10.000Z","updated_at":"2024-11-28T20:33:21.000Z","dependencies_parsed_at":"2023-08-30T17:47:53.496Z","dependency_job_id":null,"html_url":"https://github.com/barimehdi77/push_swap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/barimehdi77/push_swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barimehdi77%2Fpush_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barimehdi77%2Fpush_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barimehdi77%2Fpush_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barimehdi77%2Fpush_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barimehdi77","download_url":"https://codeload.github.com/barimehdi77/push_swap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barimehdi77%2Fpush_swap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281272677,"owners_count":26472754,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["1337","42","42cursus","algo","c","checker","pushswap","sort-data"],"created_at":"2024-12-06T23:30:33.982Z","updated_at":"2025-10-27T13:11:46.493Z","avatar_url":"https://github.com/barimehdi77.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤔 Description\nThis project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate various types of algorithms and choose the one (of many) most appropriate solution for an optimized data sorting.\n\n\n# 🔁 push_swap\n\nThe **push_swap** project is a very simple and highly effective algorithm project: data will need to be sorted. You have at your disposal a set of int values, 2 stacks and a set of instructions to manipulate both stacks.\n\nThis project contains 2 programs:\n- The first, named **checker**, which takes integer arguments and reads instructions on the standard output. Once read,checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`.\n- The second one called **push_swap** which calculates and displays on the standard output the smallest progam using *push_swap instruction language* that sorts inte-ger arguments received.\n\n## 🧰 push_swap instructions\n\n- **sa**: *swap a* - swap the first 2 elements at the top of stack a. Do nothing if there is only one or no elements.\n- **sb**: *swap b* - swap the first 2 elements at the top of stack b. Do nothing if there is only one or no elements.\n- **ss**: sa and sb at the same time.\n- **pa**: *push a* - take the first element at the top of b and put it at the top of a. Do nothing if b is empty.\n- **pb**: *push b* - take the first element at the top of a and put it at the top of b. Do nothing if a is empty.\n- **ra**: *rotate a* - shift up all elements of stack a by 1. The first element becomes the last one.\n- **rb**: *rotate b* - shift up all elements of stack b by 1. The first element becomes the last one.\n- **rr**: ra and rb at the same time.\n- **rra**: *reverse rotate a* - shift down all elements of stack a by 1. The last element becomes the first one.\n- **rrb**: *reverse rotate b* - shift down all elements of stack b by 1. The last element becomes the first one.\n- **rrr**: rra and rrb at the same time.\n\n## ⚙️ Compilation\n\nCompile checker: `make checker`\n\nCompile push_swap: `make push_swap`\n\nCompile both: `make`\n\n## 🔑 Execute\n\nchecker: `./checker 0 2 3 1` then program's waiting for user input\n\n![checker](https://github.com/barimehdi77/push_swap/blob/main/images/checker.png)\n\npush_swap: `./push_swap 0 2 3 1`\n\n![push_swap](https://github.com/barimehdi77/push_swap/blob/main/images/push_swap.png)\n\nto execute push_swap and checker: `./push_swap 7 6 5 4 3 2 1 | ./checker 7 6 5 4 3 2 1`\n\n![push_swap and checker](https://github.com/barimehdi77/push_swap/blob/main/images/push_swap_checker.png)\n\n## 👨‍💻 Tester\n\nThere is a bash script named `script.bash` that generate a random array of size n then test `push_swap | checker` till `the number of instructions \u003e= [number of max instructions]` or any error happened, then the script stops and shows you the numbers when the error happened.\n\n```\n./script.bash [how many number] [number of max instructions]\n```\n\n![script image](https://github.com/barimehdi77/push_swap/blob/main/images/script.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarimehdi77%2Fpush_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarimehdi77%2Fpush_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarimehdi77%2Fpush_swap/lists"}