{"id":25311643,"url":"https://github.com/rogeriols/push_swap-42sp","last_synced_at":"2025-04-07T12:20:04.807Z","repository":{"id":228040719,"uuid":"772827736","full_name":"RogerioLS/Push_Swap-42sp","owner":"RogerioLS","description":"push_swap is a 42 school project where we must sort random numbers with a limited set of instructions, using the lowest possible number of actions.","archived":false,"fork":false,"pushed_at":"2025-02-02T15:34:58.000Z","size":485,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T14:53:33.382Z","etag":null,"topics":["42","42cursus","42projects","42school","c","push-swap","push-swap42","pushswap","pushswap-42","sorting-algorithm","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"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/RogerioLS.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":"2024-03-16T01:57:16.000Z","updated_at":"2025-02-02T16:28:20.000Z","dependencies_parsed_at":"2024-03-16T16:39:35.504Z","dependency_job_id":"328d3c65-86ac-4828-9548-f17d02a7542b","html_url":"https://github.com/RogerioLS/Push_Swap-42sp","commit_stats":null,"previous_names":["rogeriols/push_swap-42sp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RogerioLS%2FPush_Swap-42sp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RogerioLS%2FPush_Swap-42sp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RogerioLS%2FPush_Swap-42sp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RogerioLS%2FPush_Swap-42sp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RogerioLS","download_url":"https://codeload.github.com/RogerioLS/Push_Swap-42sp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648974,"owners_count":20972945,"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","42cursus","42projects","42school","c","push-swap","push-swap42","pushswap","pushswap-42","sorting-algorithm","sorting-algorithms"],"created_at":"2025-02-13T14:53:30.906Z","updated_at":"2025-04-07T12:20:04.760Z","avatar_url":"https://github.com/RogerioLS.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align = center\u003e\n\n# 🔃 Push Swap | 42 SP\n\n![Norminette](https://github.com/RogerioLS/Push_Swap-42sp/actions/workflows/norminette.yml/badge.svg)\n![Build](https://github.com/RogerioLS/Push_Swap-42sp/actions/workflows/build.yml/badge.svg)\n![Tester Roger](https://github.com/RogerioLS/Push_Swap-42sp/actions/workflows/tester_roger-42sp.yml/badge.svg)\n![Tester Gui](https://github.com/RogerioLS/Push_Swap-42sp/actions/workflows/tester_gui-42sp.yml/badge.svg)\n![Tester Vinicius](https://github.com/RogerioLS/Push_Swap-42sp/actions/workflows/tester_vinicius-42sp.yml/badge.svg)\n![Static Badge](https://custom-icon-badges.demolab.com/badge/Push_Swap-42-blue?logo=repo)\n![42 São Paulo](https://custom-icon-badges.demolab.com/badge/42-SP-1E2952)\n![License](https://custom-icon-badges.demolab.com/github/license/RogerioLS/Push_Swap-42sp?logo=law\u0026color=dark-green)\n![Code size in bytes](https://custom-icon-badges.demolab.com/github/languages/code-size/RogerioLS/Push_Swap-42sp?logo=file-code\u0026color=dark-green)\n![Top language](https://custom-icon-badges.demolab.com/github/languages/top/RogerioLS/Push_Swap-42sp?color=dark-green)\n![Last commit](https://custom-icon-badges.demolab.com/github/last-commit/RogerioLS/Push_Swap-42sp?logo=history\u0026color=dark-green)\n![Repo size](https://custom-icon-badges.demolab.com/github/repo-size/RogerioLS/Push_Swap-42sp?logo=database)\n![Languages](https://custom-icon-badges.demolab.com/github/languages/count/RogerioLS/Push_Swap-42sp?logo=command-palette\u0026color=red)\n![GitHub repo file count (file type)](https://custom-icon-badges.demolab.com/github/directory-file-count/RogerioLS/Push_Swap-42sp%2Fsources?logo=file\u0026label=files%20sources\u0026color=8602b1)\n![Discord](https://custom-icon-badges.demolab.com/discord/1114673462859006044?\u0026logo=comments\u0026label=testemunhas%20de%20vim\u0026color=ffbe3a)\n![](https://img.shields.io/github/forks/RogerioLS/Push_Swap-42sp)\n\n\u003c/div\u003e\n\n---\n\n- Actual Status : finished.\n- Result        : Approved with 100 points ✅\n\n---\n\n### 🔷 The Mandatory part:\n1. We have at our disposal, two stacks named `a` and `b`.\n2. Create a program that takes as parameters, a random set of numbers (negative or positive), without duplicates. Our program has to handle both types of inputs: as a variable number of command line arguments; a string, i.e. \"numbers between quotation marks, seperated by a space\".\n3. Implement an algorithm, that sorts in ascending order, the input of random numbers.\n4. Our algorithm will consist of swap, rotate, reverse rotate and push operations. \n5. After taking in an input of numbers, and passing them through our sorting algorithms, our program will output the list of operations (instructions).\n\n---\n\n### 🔷 Operations:\n\n| Operation | Code | Definition |\n| --- | --- | --- |\n| **Push** | `pa`, `pb` | The topmost number in one stack is pushed to the top of the other stack. |\n| **Swap** | `sa`, `sb`, `ss` | The two topmost numbers in a given stack swap places. `ss` swaps elements in both stacks individually at the same time. |\n| **Rotate** | `ra`, `rb`, `rr` | All elements in a given stack are shifted one position up, so that the first element becomes the last one, the second becomes the first, and so on. `rr` rotates both stacks at the same time. |\n| **Reverse-rotate** | `rra`, `rrb`, `rrr` | All elements in a given stack are shifted one position below, so that the last element becomes the first one, the second but last one becomes the last one, and so on. `rrr` reverse-rotates both stacks at the same time. |\n\n\u003cimg align=\"center\" src=\"https://royalbox.com.br/github/push_swap_moves.png\"\u003e\n\n---\n\n### 🔷 Using a push_swap visualizer\n1. I can't recommend this enough. \n2. It was very useful for me to see what my code was doing during its implementation, and help with a lot of my debugging. \n3. The one I used can be found here https://github.com/o-reo/push_swap_visualizer\n\nMake sure you follow this sequence:\n1. git clone the repository inside your main push_swap directory, where your push_swap executable will be. \n2. Install the required packages as stated on the README.md (do `sudo apt update` first to make sure you have the latest information about available packages)\n3. Then, to install a package, do e.g. `sudo apt install cmake`\n4. cd inside `/push_swap_visualizer` \n5. `mkdir build`\n6. cd into `build` then:\n\t- `cmake ..`\n\t- `make`\n\t- Like myself, you might run into some build errors in your terminal. For example, you're missing a OpenGL package. I just chat gpt'd all the error messages and followed the installation commands 😅\n7. After a sucessfull build of `cmake ..` and `make`:\n\t- run `./bin/visualizer` and a window of the program should apear. \n\t- change the \"push_swap file path\" to `../../push_swap`\n\n---\n\n### 🔷 Using the checker provided by 42\n1. Download the correct file from the subject page, e.g. for Mac, or Linux, inside the same directory as your executable.\n2. Running the checker likely won't work, as it won't have the executable permission. Check by typing in the terminal `ls -l`\n3. To give it permission, do `chmod +x \u003cfilename\u003e`\n4. Test your executable against everything we need our push_swap to do:\n\t- e.g. the correct outputs for all error types\n\t- e.g. run `ARG=\"4 10 1 3 2\"; ./push_swap $ARG | ./checker_Mac $ARG `\n\t- To see how many instructions, run `ARG=\"4 10 1 3 2\"; ./push_swap $ARG | wc -l`\n\t- For our program to pass the evaluation, it'll have to return `n` size of instructions for sorting `x` number of values:\n\t\t- If x = 3 then n \u003c= 3\n\t\t- If x = 5 then n \u003c= 12\n\t\t- If x = 100 then n \u003c 1500\n\t\t- If x = 500 then n \u003c 11500\n\t\t- Note: the lesser instructions our algorithm returns, the more evaluation points we will get.\n\n---\n\n### 🔷 Running this code\nFirst off clone this repo. Then compile the program using `make`, and finally pass in a space-separated unordered list of numbers to the program `push_swap`. It will output all the stack operations that it was able to apply sequentially in order to have your list sorted in ascending order.\n```bash\ngit clone https://github.com/RogerioLS/Push_Swap-42sp\ncd Push_Swap-42sp\nmake\n./bin/push_swap 42 -42 1 2 3 0 472834 2347 -66573567\n```\nObs.: Numbers can range from -2147483648 to 2147483647. Duplicates are not allowed! Try it on and see what happens :)\n\n---\n\n### What is an algorithm?\n- A set of intructions to solve a problem.\n\n\n### What is the concept of complexity?\n- Algorithm analysis: \n\tAnalyzing the algorithm's step by step instructions to understand their performance.\n- Algorithm efficiency:\n\tLooking at how quickly an algorithm solves a problem, and the resources it uses up, like time and memory.\n- Asymptotic Notation: \n\tUsing mathematical notations like Big O, Omega and Theta to look at the algorithm's running time, as the problem becomes larger.\n- Time complexity:\n\tUsing Big O, looking at the best, worst, and average case for an algorithm to complete.\n- Space complexity:\n\tUsing Big 0, looking at the amount of memory space an algorithm uses.\n\n---\n\n\u003e [!NOTE]\n\u003e Because of 42 School norm requirements:\n\u003e * Each function can't have more than 25 lines of code.\n\u003e * All variables are declared and aligned at the top of each function.\n\u003e * Project should be created just with allowed functions otherwise it's cheating.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogeriols%2Fpush_swap-42sp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogeriols%2Fpush_swap-42sp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogeriols%2Fpush_swap-42sp/lists"}