{"id":20345795,"url":"https://github.com/izzypt/push_swap","last_synced_at":"2025-07-22T04:32:29.702Z","repository":{"id":163619884,"uuid":"638665521","full_name":"izzypt/Push_swap","owner":"izzypt","description":"This project will  sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed we have to manipulate various types of algorithms and choose the most appropriate solution (out of many) for an optimized data sorting","archived":false,"fork":false,"pushed_at":"2023-05-19T18:48:16.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T15:48:01.999Z","etag":null,"topics":[],"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/izzypt.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":"2023-05-09T20:54:41.000Z","updated_at":"2023-05-20T21:30:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"405e2479-e8c7-477a-87ac-85c8999c7644","html_url":"https://github.com/izzypt/Push_swap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/izzypt/Push_swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FPush_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FPush_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FPush_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FPush_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izzypt","download_url":"https://codeload.github.com/izzypt/Push_swap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2FPush_swap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266427933,"owners_count":23926904,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":[],"created_at":"2024-11-14T22:09:48.232Z","updated_at":"2025-07-22T04:32:29.676Z","avatar_url":"https://github.com/izzypt.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Push_swap\n\nFirst, we start with two stacks called A and B.\n\nA is filled with some random integers (without duplicate) and B is empty. \n\nWe can perform certain instructions on these stacks, and the goal is to sort all these integers with the least instructions possible.\n\n![image](https://github.com/izzypt/Push_swap/assets/73948790/5a04b89f-4ed9-48bf-bdd4-6bf56766cbb7)\n\n\n\nAnd here is the \u003cins\u003e**list of instructions**\u003c/ins\u003e that we can perform :\n\n- sa (swap a): Swap the first 2 elements at the top of stack a. \n- sb (swap b): Swap the first 2 elements at the top of stack b.\n- ss : sa and sb at the same time.\n\n![image](https://github.com/izzypt/Push_swap/assets/73948790/407c667f-1eae-47d4-a0c3-a8c337168fd3)\n\n- pa (push a): Take the first element at the top of b and put it at the top of a. \n- pb (push b): Take the first element at the top of a and put it at the top of b.\n\n![image](https://github.com/izzypt/Push_swap/assets/73948790/47290d7c-112c-4de7-8b58-bac1a6bd1785)\n\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\n![image](https://github.com/izzypt/Push_swap/assets/73948790/c5bb74b4-8d3d-47bc-8622-22ad9feea6a8)\n\n\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![image](https://github.com/izzypt/Push_swap/assets/73948790/a7ea4981-003b-48c3-b171-a48887ce7fd0)\n\n\n# Limit of actions\n\n- \u003cins\u003e**With 3 numbers**\u003c/ins\u003e, we need to sort it with not more than 3 instructions.\n\n- \u003cins\u003e**With 5 numbers**\u003c/ins\u003e, we need to sort it with not more than 12 instructions.\n\n- \u003cins\u003e**With 100 numbers**\u003c/ins\u003e, we can get\n\n  - 5 points if the size of the list of instructions is less than 700\n\n  - 4 points if the size of the list of instructions is less than 900\n\n  - 3 points if the size of the list of instructions is less than 1100\n\n  - 2 points if the size of the list of instructions is less than 1300\n\n  - 1 points if the size of the list of instructions is less than 1500\n\n- \u003cins\u003e**With 500 numbers**\u003c/ins\u003e, we can get\n\n  - 5 points if the size of the list of instructions is less than 5500\n\n  - 4 points if the size of the list of instructions is less than 7000\n\n  - 3 points if the size of the list of instructions is less than 8500\n\n  - 2 points if the size of the list of instructions is less than 10000\n\n  - 1 points if the size of the list of instructions is less than 11500\n\n\n# Implementing the stack\n\n![image](https://github.com/izzypt/Push_swap/assets/73948790/04aac693-59b3-4f62-8d3c-4fe703f03206)\n\n\n\nDecided to implement the stack by using a linked list.\n\n![image](https://github.com/izzypt/Push_swap/assets/73948790/7486eb4f-bb2f-4a45-ba97-ca808055e89d)\n\nUsed the following tester:\n\n- https://github.com/laisarena/push_swap_tester\n\n\n### Another helpfull topics :\n\nhttps://medium.com/@jamierobertdawson/push-swap-the-least-amount-of-moves-with-two-stacks-d1e76a71789a\n\nhttps://medium.com/nerd-for-tech/push-swap-tutorial-fa746e6aba1e\n\nhttps://medium.com/@ayogun/push-swap-c1f5d2d41e97\n\nhttps://zainab-dnaya.medium.com/fastest-push-swap-algorithm-2f510028602b\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fpush_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizzypt%2Fpush_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fpush_swap/lists"}