{"id":19053293,"url":"https://github.com/jotavare/push_swap","last_synced_at":"2026-02-13T02:03:52.465Z","repository":{"id":155284589,"uuid":"613314342","full_name":"jotavare/push_swap","owner":"jotavare","description":"Algorithm project where I must sort a given list of random numbers with a limited set of instructions, using the lowest possible number of actions.","archived":false,"fork":false,"pushed_at":"2024-06-26T23:16:11.000Z","size":1585,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-27T02:54:31.796Z","etag":null,"topics":["algorithms","binary","c","data-structures","efficiency","gdb","makefile","norminette","performance","quicksort","radix","sorting-algorithms","stacks","valgrind"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jotavare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-03-13T10:32:02.000Z","updated_at":"2024-06-26T23:18:50.000Z","dependencies_parsed_at":"2023-12-02T23:20:40.666Z","dependency_job_id":"83e36277-d9da-4a22-98fb-8e5079a381e2","html_url":"https://github.com/jotavare/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/jotavare%2Fpush_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jotavare%2Fpush_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jotavare%2Fpush_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jotavare%2Fpush_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jotavare","download_url":"https://codeload.github.com/jotavare/push_swap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768227,"owners_count":17199323,"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":["algorithms","binary","c","data-structures","efficiency","gdb","makefile","norminette","performance","quicksort","radix","sorting-algorithms","stacks","valgrind"],"created_at":"2024-11-08T23:29:59.702Z","updated_at":"2026-02-13T02:03:47.447Z","avatar_url":"https://github.com/jotavare.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/jotavare/jotavare/blob/main/42/banners/piscine_and_common_core/github_piscine_and_common_core_banner_push_swap.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://img.shields.io/badge/status-finished-success?color=%2312bab9\u0026style=flat-square\" /\u003e\n\t\u003cimg src=\"https://img.shields.io/badge/evaluated-03%20%2F%2004%20%2F%202023-success?color=%2312bab9\u0026style=flat-square\" /\u003e\n\t\u003cimg src=\"https://img.shields.io/badge/score-84%20%2F%20100-success?color=%2312bab9\u0026style=flat-square\" /\u003e\n\t\u003cimg src=\"https://img.shields.io/github/languages/top/jotavare/libft?color=%2312bab9\u0026style=flat-square\" /\u003e\n\t\u003cimg src=\"https://img.shields.io/github/last-commit/jotavare/libft?color=%2312bab9\u0026style=flat-square\" /\u003e\n\t\u003ca href='https://www.linkedin.com/in/jotavare' target=\"_blank\"\u003e\u003cimg alt='Linkedin' src='https://img.shields.io/badge/LinkedIn-blue?style=flat-square'/\u003e\u003c/a\u003e\n\t\u003ca href='https://profile.intra.42.fr/users/jotavare' target=\"_blank\"\u003e\u003cimg alt='42' src='https://img.shields.io/badge/Porto-100000?style=flat-square\u0026logo=42\u0026logoColor=white\u0026labelColor=000000\u0026color=000000'/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"#about\"\u003eAbout\u003c/a\u003e •\n\t\u003ca href=\"#how-to-use\"\u003eHow to use\u003c/a\u003e •\n\t\u003ca href=\"#mandatory\"\u003eMandatory\u003c/a\u003e •\n\t\u003ca href=\"#bonus\"\u003eBonus\u003c/a\u003e •\n\t\u003ca href=\"#norminette\"\u003eNorminette\u003c/a\u003e •\n\t\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e •\n\t\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\n## ABOUT\nIn this project, I developed a sorting algorithm for a specific problem using two stacks. The goal of the project is to efficiently sort a stack of integers using a set of predefined operations.\n\n## HOW TO USE\n#### 1º - Clone the repository\n```bash\ngit clone git@github.com:jotavare/push_swap.git\n```\n#### 2º - Enter the project folder and run `make`\n```bash\ncd push_swap/push_swap\nmake\n```\n#### 3º - Run the code\n\u003e If you have problems running the `./checker`, use `chmod 777 ./checker` and try again.\n```bash\n./push_swap [numbers] | ./checker [numbers]\n./push_swap 9 0 -217 2147483647 -2147483648 | ./checker 9 0 -217 2147483647 -2147483648\n```\n#### 4º - Assign numbers to a variable and run the code\n```bash\nARG=[\"numbers\"]; ./push_swap $ARG | ./checker $ARG\nARG=\"3 0 9 2 -1\"; ./push_swap $ARG | ./checker $ARG\n```\n\n#### MAKEFILE RULES\n\n`make` - Compile push_swap **mandatory** functions.\n\n`make bonus` - Compile push_swap **bonus** functions.\n\n`make all` - Compile **mandatory** + **bonus** functions.\n\n`make clean` - Delete all .o (object files) files.\n\n`make fclean` - Delete all .o (object files) and .a (executable) files.\n\n`make re` - Use rules `fclean` + `all`.\n\n\n## MANDATORY\n#### RULES\n\u003e The program is only allowed to work with two stacks, stack A and stack B. All the numbers are initially added to stack A, and B is empty.\n\nPossible actions:\n- [x] `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- [x] `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- [x] `sa` **(swap A)**: Swap the first 2 elements at the top of stack A. Do nothing if there are only one or no elements.\n- [x] `sb` **(swap B)**: Swap the first 2 elements at the top of stack B. Do nothing if there are only one or no elements.\n- [x] `ss`: `sa` and `sb` at the same time.\n- [x] `ra` **(rotate A)**: Shift all elements of stack A up by 1. The first element becomes the last one.\n- [x] `rb` **(rotate B)**: Shift all elements of stack B up by 1. The first element becomes the last one.\n- [x] `rr` : `ra` and `rb` at the same time.\n- [x] `rra` **(reverse rotate A)**: Shift all elements of stack A down by 1. The last element becomes the first one.\n- [x] `rrb` **(reverse rotate B)**: Shift all elements of stack b down by 1. The last element becomes the first one.\n- [x] `rrr` : `rra` and `rrb` at the same time.\n\n#### GRADE\n\u003e The grade depends on how efficient the program's sorting process is.\n \n- [x] Sorting **3 values**: no more than **3 actions**.\n- [x] Sorting **5 values**: no more than **12 actions**.\n- [x] Sorting **100 values**: **rating from 1 to 5 points** depending on the number of actions:\n\n   - [ ] **5 points** for less than **700 actions**.\n   - [ ] **4 points** for less than **900 actions**.\n   - [x] **3 points** for less than **1100 actions**.\n   - [x] **2 points** for less than **1300 actions**.\n   - [x] **1 point** for less than **1500 actions**.\n- [x] Sorting **500 values**: **rating from 1 to 5 points** depending on the number of actions:\n\n   - [ ] **5 points** for less than **5500 actions**.\n   - [x] **4 points** for less than **7000 actions**.\n   - [x] **3 points** for less than **8500 actions**.\n   - [x] **2 points** for less than **10000 actions**.\n   - [x] **1 point** for less than **11500 actions**.\n\n\u003e Note: Validating the project requires at least 80/100. I believe 3 points with 100 and 500 numbers would be 80/100.\n\n#### ERROR MANAGEMENT\n\u003e The program should print `Error` + `\\n` if the following tests are made:\n\n- [x] Non-numeric parameters.\n- [x] Duplicate numeric parameter.\n- [x] Numeric parameter greater than INT_MAX.\n- [x] Numeric parameter less than INT_MIN.\n\n```bash\n./push_swap 4 bb 2\n./push_swap 4 4 5\n./push_swap 4 2 2147483648\n./push_swap 4 2 -2147483649\n```\n\n#### SORTED EXAMPLES\n\u003e Should not print anything if the following tests are made:\n\n- [x] No parameter.\n- [x] Single numeric argument.\n- [x] The numbers are already sorted.\n\n```bash\n./push_swap\n./push_swap 42\n./push_swap 0 1 2 3\n./push_swap 0 1 2 3 4 5 6 7 8 9\n```\n\n## BONUS\n- [ ] Create a checker for push_swap that will read the program instructions and display `KO` or `OK`.\n\n## NORMINETTE\n\u003e At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.\n\n```\n- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;\n- Each function must be a maximum of 25 lines, not counting the function's curly brackets;\n- Each line must be at most 80 columns wide, with comments included;\n- A function can take 4 named parameters maximum;\n- No assigns and declarations in the same line (unless static);\n- You can't declare more than 5 variables per function;\n- ...\n```\n\n* [42 Norms](https://github.com/42School/norminette/blob/master/pdf/en.norm.pdf) - Information about 42 code norms. `PDF`\n* [Norminette](https://github.com/42School/norminette) - Tool to respect the code norm, made by 42. `GitHub`\n* [42 Header](https://github.com/42Paris/42header) - 42 header for Vim. `GitHub`\n\n## CONTRIBUTING\n\nIf you find any issues or have suggestions for improvements, feel free to fork the repository and open an issue or submit a pull request.\n\n## LICENSE\n\nThis project is available under the MIT License. For further details, please refer to the [LICENSE](https://github.com/jotavare/push_swap/blob/master/LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjotavare%2Fpush_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjotavare%2Fpush_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjotavare%2Fpush_swap/lists"}