{"id":18879456,"url":"https://github.com/tjensen42/42-push_swap","last_synced_at":"2026-02-20T02:30:15.875Z","repository":{"id":113618687,"uuid":"422501976","full_name":"tjensen42/42-push_swap","owner":"tjensen42","description":"push_swap will sort random integers on a stack, with a limited set of instructions, trying to use the least stack operations to get a sorted stack. ","archived":false,"fork":false,"pushed_at":"2022-12-02T17:40:00.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T03:11:57.604Z","etag":null,"topics":["42project","c","c-sorting-algotihms","stack-sorting"],"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/tjensen42.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-10-29T08:39:30.000Z","updated_at":"2023-09-07T19:49:04.000Z","dependencies_parsed_at":"2023-11-10T12:24:38.169Z","dependency_job_id":null,"html_url":"https://github.com/tjensen42/42-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/tjensen42%2F42-push_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-push_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-push_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-push_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjensen42","download_url":"https://codeload.github.com/tjensen42/42-push_swap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239841743,"owners_count":19705981,"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":["42project","c","c-sorting-algotihms","stack-sorting"],"created_at":"2024-11-08T06:36:31.891Z","updated_at":"2026-02-20T02:30:13.814Z","avatar_url":"https://github.com/tjensen42.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 42-push_swap\n\nThe program push_swap will sort random integers on a stack, with a limited set of instructions, trying to use the least stack operations to get an ascending sorted stack.\n\n## How to use it\n0. Clone the repo\n1. Call ```make release```\n3. Start program with your own input: ```./push_swap [put your args seperated by spaces]```\n4. Start program with 500 random ints: ```./push_swap `ruby -e \"puts (0..499).to_a.shuffle.join(' ')\"` ```\n\n## \"Game Rules\"\n\n\u003cb\u003eThe game is composed of 2 stacks named A and B.\u003c/b\u003e\n\n\u003cb\u003eStarting Point:\u003c/b\u003e\n- Stack_A contains random numbers of either positive or negative numbers without any duplicates.\n- Stack_B is empty\n\n\u003cb\u003eThe goal is to sort in ascending order numbers into stack.\u003c/b\u003e\n\n\u003cb\u003eThe operations the program can do, are limited to the following set:\u003c/b\u003e\n\n| Operations    | Description                                                                           |\n| ------------- | --------------------------------------------------------------------------------------|\n| \u003cb\u003esa\u003c/b\u003e     | swap a - swap the first 2 elements at the top of stack a. Do nothing if there is only one or no elements) |\n| \u003cb\u003esb\u003c/b\u003e     | swap b - swap the first 2 elements at the top of stack b. Do nothing if there is only one or no elements) |\n| \u003cb\u003ess\u003c/b\u003e     | sa and sb at the same time |\n| \u003cb\u003epa\u003c/b\u003e     | 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| \u003cb\u003epb\u003c/b\u003e     | 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| \u003cb\u003era\u003c/b\u003e     | rotate a - shift up all elements of stack a by 1. The first element becomes the last one |\n| \u003cb\u003erb\u003c/b\u003e     | rotate b - shift up all elements of stack b by 1. The first element becomes the last one |\n| \u003cb\u003err\u003c/b\u003e     | ra and rb at the same time |\n| \u003cb\u003erra\u003c/b\u003e    | reverse rotate a - shift down all elements of stack a by 1. The last element becomes the first one |\n| \u003cb\u003errb\u003c/b\u003e    | reverse rotate b - shift down all elements of stack b by 1. The last element becomes the first one |\n| \u003cb\u003errr\u003c/b\u003e    | rra and rrb at the same time |\n\n\n\u003chr\u003e\n\n### Sample sorting animation for 100 integers:\n\n*Visualized with the great push_swap [visualizer](https://github.com/o-reo/push_swap_visualizer) from [o-reo](https://github.com/o-reo). I really appreciate this visualiser, it helped a lot to find strange behaviour of the sorting algorithms. \n\n![push_swap-animation](https://user-images.githubusercontent.com/56789534/137463054-e642a7d5-711d-4f25-bf55-03b47d8fcfc3.gif)\n\n\u003chr\u003e\n\u003cb\u003e*All 42 projects must be written in C (later C++) in accordance to the 42 School Norm.\u003cbr\u003e\u003c/b\u003e\n\u003cbr\u003e\n\n\u003e #### Sample restrictions:\n\u003e - All variables have to be declared and aligned at the top of each function\n\u003e - Each function can not have more then 25 lines\n\u003e - Projects should be created with allowed std functions otherwise it is cheating\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjensen42%2F42-push_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjensen42%2F42-push_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjensen42%2F42-push_swap/lists"}