{"id":19483544,"url":"https://github.com/librity/ft_push_swap","last_synced_at":"2025-10-06T18:41:21.314Z","repository":{"id":46885401,"uuid":"487391670","full_name":"librity/ft_push_swap","owner":"librity","description":"42 São Paulo - push_swap","archived":false,"fork":false,"pushed_at":"2022-08-18T15:13:15.000Z","size":1455,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T17:46:14.628Z","etag":null,"topics":["42","42born2code","42cursus","42projects","42saopaulo","42school","c","gcc","optimization","pushswap","sorting","sorting-algorithms","stacks"],"latest_commit_sha":null,"homepage":"https://www.42sp.org.br/","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/librity.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}},"created_at":"2022-04-30T22:09:36.000Z","updated_at":"2022-08-22T22:55:15.000Z","dependencies_parsed_at":"2022-08-12T13:10:38.734Z","dependency_job_id":null,"html_url":"https://github.com/librity/ft_push_swap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/librity/ft_push_swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fft_push_swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fft_push_swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fft_push_swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fft_push_swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/librity","download_url":"https://codeload.github.com/librity/ft_push_swap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librity%2Fft_push_swap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261445030,"owners_count":23159177,"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","42born2code","42cursus","42projects","42saopaulo","42school","c","gcc","optimization","pushswap","sorting","sorting-algorithms","stacks"],"created_at":"2024-11-10T20:15:30.512Z","updated_at":"2025-10-06T18:41:21.226Z","avatar_url":"https://github.com/librity.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch3 align=\"center\"\u003e42 São Paulo - push_swap\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![42 São Paulo](https://img.shields.io/badge/42-SP-1E2952)\n![License](https://img.shields.io/github/license/librity/ft_push_swap?color=yellow)\n![Code size in bytes](https://img.shields.io/github/languages/code-size/librity/ft_push_swap?color=blue)\n![Lines of code](https://img.shields.io/tokei/lines/github/librity/ft_push_swap?color=blueviolet)\n![Top language](https://img.shields.io/github/languages/top/librity/ft_push_swap?color=ff69b4)\n![Last commit](https://img.shields.io/github/last-commit/librity/ft_push_swap?color=orange)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build](https://github.com/librity/ft_push_swap/actions/workflows/build.yml/badge.svg)](https://github.com/librity/ft_push_swap/actions/workflows/build.yml)\n[![Norminette v3](https://github.com/librity/ft_push_swap/actions/workflows/norminette_v3.yml/badge.svg)](https://github.com/librity/ft_push_swap/actions/workflows/norminette_v3.yml)\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e An exercise on Sorting Algorithms and Efficiency in pure C.\n  \u003cbr\u003e\n\u003c/p\u003e\n\n---\n\n## 📜 Table of Contents\n\n- [About](#about)\n- [Checklist](#checklist)\n- [Getting Started](#getting_started)\n- [Notes](#notes)\n- [42 São Paulo](#ft_sp)\n- [Resources](#resources)\n\n## 🧐 About \u003ca name = \"about\"\u003e\u003c/a\u003e\n\n### Sorter\n\nThis program that takes a list of `int`s as arguments:\n\n```bash\n$ ./push_swap 7 1 8 9 4 2 6 5 3\n```\n\nParses them into `stack a`:\n\n```elixir\n|A: (top) 7 1 8 9 4 2 6 5 3 (bottom)|\n|B: (top) (bottom)|\n```\n\nThen sorts them with `stack b` and the operations:\n\n- `sa` (swap a): Swap the first 2 elements at the top of `stack a`:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nsa\n|A: (top) 6 2 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\n```\n\n- `sb` (swap b): Swap the first 2 elements at the top of `stack b`:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nsb\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 1 7 8 9 4 (bottom)|\n```\n\n- `ss` : `sa` and `sb` at the same time:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nsb\n|A: (top) 6 2 5 3 (bottom)|\n|B: (top) 1 7 8 9 4 (bottom)|\n```\n\n- `pa` (push a): Take the first element at the top of b and put it at the top of a:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\npa\n|A: (top) 7 2 6 5 3 (bottom)|\n|B: (top) 1 8 9 4 (bottom)|\n```\n\n- `pb` (push b): Take the first element at the top of a and put it at the top of b:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\npa\n|A: (top) 6 5 3 (bottom)|\n|B: (top) 2 7 1 8 9 4 (bottom)|\n```\n\n- `ra` (rotate a): The first element becomes the last one:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nra\n|A: (top) 6 5 3 2 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\n```\n\n- `rb` (rotate b): The first element becomes the last one:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nrb\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 1 8 9 4 7 (bottom)|\n```\n\n- `rr` : `ra` and `rb` at the same time:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nrr\n|A: (top) 6 5 3 2 (bottom)|\n|B: (top) 1 8 9 4 7 (bottom)|\n```\n\n- `rra` (reverse rotate a): The last element becomes the first one:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nrra\n|A: (top) 3 2 6 5 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\n```\n\n- `rrb` (reverse rotate b): The last element becomes the first one:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\n\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 4 7 1 8 9 (bottom)|\n```\n\n- `rrr` : `rra` and `rrb` at the same time:\n\n```elixir\n|A: (top) 2 6 5 3 (bottom)|\n|B: (top) 7 1 8 9 4 (bottom)|\nrrr\n|A: (top) 3 2 6 5 (bottom)|\n|B: (top) 4 7 1 8 9 (bottom)|\n```\n\n`stack a` must be sorted from smallest to largest:\n\n```elixir\n|A: (top) 0 1 2 3 4 5 6 7 8 (bottom)|\n|B: (top) (bottom)|\nIs sorted: YES\n```\n\nThe more operations it takes to sort, the lower your grade.\n\nI enjoyed the project and learned a lot about doubly linked lists,\nsorting algorithms and optimizations.\nI especially liked the optimization aspect of it:\nit's not as easy as implementing some random sorting algorithm\nwith a good average performance when\n[the cost of swapping two arbitrary numbers is so high](./sources/mandatory/sorters/quick.c).\nThe limitation of the stack and it's operations challenge you to\nthink outside the box and understand the entire workflow of your solutions.\n\n### Checker\n\nThe checker program takes a list of `int`s as arguments and\na list of operations from `STDIN`.\nIt then executes all operations and checks if it properly sorts the stack:\n\n```bash\n$ ./checker 3 2 1 0\nsa\nrra\npb\nKO\n```\n\n```bash\n$ ./checker 3 2 1 0\nrra\npb\nsa\nrra\npa\nOK\n```\n\n## ✅ Checklist \u003ca name = \"checklist\"\u003e\u003c/a\u003e\n\n### Mandatory\n\n- [x] DON'T TURN IN LIBS AS SUBMODULES\n- [x] MAKEFILE EXPLICIT SOURCE FILES (`echo M_SOURCES`)\n- [x] Make must compile without relinking\n  - [x] SHOOULDNT RECOMPILE/REARCHIVE OBJECTS WITH MAKE ALL\n- [x] `.linux` file (42 Workspaces)\n- [x] Test in workspaces\n- [x] Follows `norminette 3.3.51`\n- [x] Turn in `Makefile`, `*.h`, `*.c` , `.linux` , `.gitignore`\n- [x] Makefile rules: `$(NAME)` `all` `clean` `fclean` `re`\n- [x] Program name `push_swap`\n- [x] Compiles with `-Wall -Wextra -Werror`\n- [x] Should not quit unexpectedly (segmentation fault, bus error, double\n      free, etc.)\n- [x] All allocated heap memory properly freed, no memory leaks.\n  - [x] Check memory leaks with `valgrind`\n- [x] Allowed functions:\n  - [x] `read`, `write`, `malloc`, `free`, `exit`\n  - [x] `libft` allowed\n  - [x] Your `ft_printf` (may be modified)\n    - [x] No `printf` from `stdio.h`\n- [x] Handle arguments `list of integers`\n  - [x] If no arguments are specified (`argc == 1`) then exits with `EXIT_SUCCESS`\n  - [x] If arguments aren’t all `int` then exits with `\"Error\\n\"` to `STDERR_FILENO`\n  - [x] If any argument is bigger than **`INT_MAX`** then exits with `\"Error\\n\"` to `STDERR_FILENO`\n  - [x] If any argument is smaller than **`INT_MIN`** then exits with `\"Error\\n\"` to `STDERR_FILENO`\n  - [x] If any argument is a duplicate then exits with `\"Error\\n\"` to `STDERR_FILENO`\n- [x] Implement stack `a` and `b`\n- [x] Implement all operations\n  - [x] `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  - [x] `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  - [x] `ss` : `sa` and `sb` at the same time.\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] `ra` (rotate a): Shift up all elements of `stack a` by 1. The first element becomes the last one.\n  - [x] `rb` (rotate b): Shift up all elements of `stack b` 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 down all elements of `stack a` by 1. The last element becomes the first one.\n  - [x] `rrb` (reverse rotate b): Shift down all elements of `stack b` by 1. The last element becomes the first one.\n  - [x] `rrr` : `rra` and `rrb` at the same time.\n- [x] Print the list of instructions separated by `'\\n'` to `STDOUT_FILENO`\n- [x] Implement radix sort for 84% score.\n- [x] Implement best rotation sort for 100% score.\n- [x] Pass all testers\n  - [x] [https://github.com/laisarena/push_swap_tester](https://github.com/laisarena/push_swap_tester)\n  - [x] [https://github.com/lmalki-h/push_swap_tester](https://github.com/lmalki-h/push_swap_tester)\n  - [x] [https://github.com/minckim42/push_swap_tester](https://github.com/minckim42/push_swap_tester)\n  - [x] [https://github.com/wwwwelton/push_swap/blob/master/tester.sh](https://github.com/wwwwelton/push_swap/blob/master/tester.sh)\n  - [x] [https://github.com/VBrazhnik/Push_swap/blob/master/benchmark.sh](https://github.com/VBrazhnik/Push_swap/blob/master/benchmark.sh)\n\n### Bonus\n\n- [x] Create a checker program\n  - [x] Takes the `stack a`s `argv`\n  - [x] If the stack has any problem then exits with `\"Error\\n\"` to `STDERR_FILENO`\n  - [x] Takes the operations from `STDIN` up to `EOF` (`Ctrl+D`) and saves them to a linked list.\n  - [x] If the operations have any problem then exits with `\"Error\\n\"` to `STDERR_FILENO`\n  - [x] If the operations sort the stack then exits with `\"OK\\n\"` to `STDOUT_FILENO`\n  - [x] If the operations doesn’t sort the stack then exits with `\"KO\\n\"` to `STDOUT_FILENO`\n\n## 🏁 Getting Started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\n\n### 🖥️ Installing\n\nClone the repo and build with `make`:\n\n```bash\n$ git clone --recurse-submodules https://github.com/librity/ft_push_swap.git\n$ cd ft_push_swap\n$ make\n```\n\n### Sorter\n\nYou give it a list of integers and it prints the sorting instructions to `STDOUT`:\n\n```bash\n$ ./push_swap 7 1 8 9\nra\npb\nrra\npa\n```\n\nYou can also [compile it with `verbose` mode](./sources/mandatory/control/core.c) for more details:\n\n```elixir\n$ ./push_swap 7 1 8 9\n|A: (top) 7 1 8 9 (bottom)|\n|B: (top) (bottom)|\nIs sorted: NO\n\nNORMALIZED STACK\n|A: (top) 1 0 2 3 (bottom)|\n|B: (top) (bottom)|\nIs sorted: NO\n\nra\n|A: (top) 0 2 3 1 (bottom)|\n|B: (top) (bottom)|\nIs sorted: NO\n\npb\n|A: (top) 2 3 1 (bottom)|\n|B: (top) 0 (bottom)|\nIs sorted: NO\n\nrra\n|A: (top) 1 2 3 (bottom)|\n|B: (top) 0 (bottom)|\nIs sorted: NO\n\npa\n|A: (top) 0 1 2 3 (bottom)|\n|B: (top) (bottom)|\nIs sorted: YES\n```\n\nFor more examples see the tester script:\n\n```bash\n$ ./scripts/run.sh\n```\n\n## 📝 Notes \u003ca name = \"notes\"\u003e\u003c/a\u003e\n\nI implemented [many](./sources/mandatory/sorters)\n[sorting](./sources/mandatory/insertion_v1)\n[algorithms](./sources/mandatory/insertion_v2)\nbefore I found a good enough solution for a full grade.\n\nDue to the nature of this problem\nsomething like insertion sort with chunks is one of the best options.\nThe [final sorter](./sources/mandatory/insertion_v2) sends all\nelements to `stack b` by group/chunk, so the biggest are at the top\nand the smallest are at the bottom.\nThey're not completely sorted but they're roughly were they need to be.\n\nIt then pushes all the numbers back to `stack a`\nwhile maintaining `stack a` in order.\nThat means we need to rotate some number to the top of `stack b`\nand then rotate the greatest closest number to it to the top of `stack a`.\nIt finds the number of `stack b` that will take the least amount of rotations\nbefore pushing it to `stack a`,\nthen executes that rotation and pushes it.\n\nCalculating the rotations is [pretty straight forward](./sources/mandatory/insertion_v2/set_rotations.c):\n\n- The number of normal rotations (`ra` and `rb`) is the index of the number.\n- The number of reverse rotations (`rra` and `rrb`) is the size of the stack minus the index.\n- If we're doing the same type of rotation on both stacks we can optimize it further with `rr` and `rrr`.\n- The total number of operations is the sum of all the rotations.\n\nWith a few while loops we can find the best rotation for each number,\nand then find the best rotation for all numbers.\n\n## 🛸 42 São Paulo \u003ca name = \"ft_sp\"\u003e\u003c/a\u003e\n\nPart of the larger [42 Network](https://www.42.fr/42-network/),\n[42 São Paulo](https://www.42sp.org.br/) is a software engineering school\nthat offers a healthy alternative to traditional education:\n\n- It doesn't have any teachers and classes.\n- Students learn by cooperating\n  and correcting each other's work (peer-to-peer learning).\n- Its focus is as much on social skills as it is on technical skills.\n- It's completely free to anyone that passes its selection process -\n  [**The Piscine**](https://42.fr/en/admissions/42-piscine/)\n\nIt's an amazing school, and I'm grateful for the opportunity.\n\n## 📚 Resources \u003ca name = \"resources\"\u003e\u003c/a\u003e\n\n### Linked Lists\n\n- [https://visualgo.net/en/list](https://visualgo.net/en/list)\n- [https://www.geeksforgeeks.org/linked-list-set-1-introduction/](https://www.geeksforgeeks.org/linked-list-set-1-introduction/)\n- [https://www.geeksforgeeks.org/circular-linked-list/](https://www.geeksforgeeks.org/circular-linked-list/)\n- [https://www.geeksforgeeks.org/doubly-linked-list/](https://www.geeksforgeeks.org/doubly-linked-list/)\n- [https://www.geeksforgeeks.org/xor-linked-list-a-memory-efficient-doubly-linked-list-set-1/](https://www.geeksforgeeks.org/xor-linked-list-a-memory-efficient-doubly-linked-list-set-1/)\n- [https://www.geeksforgeeks.org/move-first-element-to-end-of-a-given-linked-list/](https://www.geeksforgeeks.org/move-first-element-to-end-of-a-given-linked-list/)\n- [https://www.geeksforgeeks.org/move-last-element-to-front-of-a-given-linked-list/](https://www.geeksforgeeks.org/move-last-element-to-front-of-a-given-linked-list/)\n\n### Stacks\n\n- [https://wikiless.org/wiki/Stack\\_(abstract_data_type)?lang=en](\u003chttps://wikiless.org/wiki/Stack_(abstract_data_type)?lang=en\u003e)\n- [https://www.geeksforgeeks.org/stack-data-structure/?ref=lbp](https://www.geeksforgeeks.org/stack-data-structure/?ref=lbp)\n\n### Tutorials\n\n- [https://medium.com/nerd-for-tech/push-swap-tutorial-fa746e6aba1e](https://medium.com/nerd-for-tech/push-swap-tutorial-fa746e6aba1e)\n- [https://medium.com/@jamierobertdawson/push-swap-the-least-amount-of-moves-with-two-stacks-d1e76a71789a](https://medium.com/@jamierobertdawson/push-swap-the-least-amount-of-moves-with-two-stacks-d1e76a71789a)\n- [https://docs.google.com/presentation/d/1c2PU6ZST7uMwNHl6aAz2WsJ5QFf1J7JJsMkW0VSTXc8/edit#slide=id.gc7df47266a_0_336](https://docs.google.com/presentation/d/1c2PU6ZST7uMwNHl6aAz2WsJ5QFf1J7JJsMkW0VSTXc8/edit#slide=id.gc7df47266a_0_336)\n- [https://42born2code.slack.com/?redir=%2Farchives%2FC3QG85SG6%2Fp1629127318173200%3Fthread_ts%3D1629126645.172700%26cid%3DC3QG85SG6](https://42born2code.slack.com/?redir=%2Farchives%2FC3QG85SG6%2Fp1629127318173200%3Fthread_ts%3D1629126645.172700%26cid%3DC3QG85SG6)\n- [https://github.com/VBrazhnik/Push_swap/wiki/Algorithm](https://github.com/VBrazhnik/Push_swap/wiki/Algorithm)\n- [https://github.com/LeoFu9487/push_swap_tutorial](https://github.com/LeoFu9487/push_swap_tutorial)\n\n### Sorting Algorithms\n\n- [https://visualgo.net/en/sorting](https://visualgo.net/en/sorting)\n- [https://www.geeksforgeeks.org/sorting-algorithms/](https://www.geeksforgeeks.org/sorting-algorithms/)\n- [https://www.crio.do/blog/top-10-sorting-algorithms/](https://www.crio.do/blog/top-10-sorting-algorithms/)\n- [https://cs.stackexchange.com/questions/18536/what-is-a-the-fastest-sorting-algorithm-for-an-array-of-integers](https://cs.stackexchange.com/questions/18536/what-is-a-the-fastest-sorting-algorithm-for-an-array-of-integers)\n- [https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html](https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html)\n- [https://www.toptal.com/developers/sorting-algorithms](https://www.toptal.com/developers/sorting-algorithms)\n- [https://github.com/cjbt/Free-Algorithm-Books/blob/master/book/Grokking Algorithms - An illustrated guide for programmers and other curious people.pdf](https://github.com/cjbt/Free-Algorithm-Books/blob/master/book/Grokking%20Algorithms%20-%20An%20illustrated%20guide%20for%20programmers%20and%20other%20curious%20people.pdf)\n- [https://pastebin.com/s6nn85KZ](https://pastebin.com/s6nn85KZ)\n- https://en.wikipedia.org/wiki/Sorting_algorithm\n- https://en.wikipedia.org/wiki/Quicksort\n- https://en.wikipedia.org/wiki/Block_sort\n- https://github.com/vbohush/SortingAlgorithmAnimations\n- https://github.com/caisah/Sedgewick-algorithms-in-c-exercises-and-examples\n- https://github.com/cdmh/sorting_algorithms\n- https://github.com/ismdeep/sort-algos-c\n- https://www.sanfoundry.com/c-program-sort-array-ascending-order/\n- https://www.dummies.com/programming/c/how-to-sort-arrays-in-c-programming/\n- https://www.geeksforgeeks.org/c-program-to-sort-an-array-in-ascending-order/\n- https://stackoverflow.com/questions/3893937/sorting-an-array-in-c\n- https://www.edureka.co/blog/sorting-algorithms-in-c/\n- https://codeforwin.org/2015/07/c-program-to-sort-array-in-ascending-order.html\n- https://www.educba.com/sorting-in-c/\n- http://www.firmcodes.com/sorting-algorithms-in-c/\n- https://www.tutorialride.com/c-programming/sorting-in-c-programming.htm\n- https://stackoverflow.com/questions/22186423/array-of-random-numbers-using-c-program\n\n### Quick Sort\n\n- [https://joaoarthurbm.github.io/eda/posts/quick-sort/](https://joaoarthurbm.github.io/eda/posts/quick-sort/)\n\n### Radix Sort\n\n- [https://en.wikipedia.org/wiki/Radix_sort](https://en.wikipedia.org/wiki/Radix_sort)\n- [https://www.geeksforgeeks.org/radix-sort/](https://www.geeksforgeeks.org/radix-sort/)\n\n### **`INT_MIN` \u0026** **`INT_MAX`**\n\n- [https://www.geeksforgeeks.org/int_max-int_min-cc-applications/](https://www.geeksforgeeks.org/int_max-int_min-cc-applications/)\n- [https://en.cppreference.com/w/c/types/limits](https://en.cppreference.com/w/c/types/limits)\n\n```c\nValue of INT_MAX is +2147483647.\nValue of INT_MIN is -2147483648.\n```\n\n### `STDERR_FILENO`\n\n- [https://www.cyberciti.biz/faq/how-to-redirect-output-and-errors-to-devnull/](https://www.cyberciti.biz/faq/how-to-redirect-output-and-errors-to-devnull/)\n\n```bash\n./push_swap \u003e /dev/null 2\u003e\u00261\n./push_swap 1 2 3 \u003e /dev/null 2\u003e\u00261\n./push_swap \u0026\u003e /dev/null\n./push_swap 1 2 3 \u0026\u003e /dev/null\n\n./push_swap 1 2 3 \u003estdout 2\u003estderr\n./push_swap 3 14 -41 \u003estdout 2\u003estderr\n```\n\n### Testers\n\n- [https://github.com/LeoFu9487/push_swap_tester](https://github.com/LeoFu9487/push_swap_tester)\n- [https://github.com/lmalki-h/push_swap_tester](https://github.com/lmalki-h/push_swap_tester)\n- [https://github.com/laisarena/push_swap_tester](https://github.com/laisarena/push_swap_tester)\n- [https://github.com/minckim42/push_swap_tester](https://github.com/minckim42/push_swap_tester)\n- [https://github.com/wwwwelton/push_swap/blob/master/tester.sh](https://github.com/wwwwelton/push_swap/blob/master/tester.sh)\n- [https://github.com/VBrazhnik/Push_swap/blob/master/benchmark.sh](https://github.com/VBrazhnik/Push_swap/blob/master/benchmark.sh)\n\n### Visualizers\n\n- [https://github.com/o-reo/push_swap_visualizer](https://github.com/o-reo/push_swap_visualizer)\n- [https://github.com/elijahkash/push_swap_gui](https://github.com/elijahkash/push_swap_gui)\n- [https://github.com/o-reo/push_swap_visualizer](https://github.com/o-reo/push_swap_visualizer)\n- [https://phemsi-a.itch.io/push-swap](https://phemsi-a.itch.io/push-swap)\n\n### Random Numbers\n\n- [https://randomnumbergenerator.org/](https://randomnumbergenerator.org/)\n- https://stackoverflow.com/questions/35613298/implicit-declaration-of-functions-srand-rand-and-system\n- https://www.tutorialspoint.com/c_standard_library/c_function_rand.htm\n- [https://stackoverflow.com/questions/822323/how-to-generate-a-random-int-in-c](https://stackoverflow.com/questions/822323/how-to-generate-a-random-int-in-c)\n- [https://www.calculatorsoup.com/calculators/statistics/random-number-generator.php](https://www.calculatorsoup.com/calculators/statistics/random-number-generator.php)\n\n```bash\nLIST=$(ruby -e \"puts (1..500).to_a.shuffle.join(' ')\"); ./push_swap $LIST | ./checker_linux $LIST\nLIST=$(ruby -e \"puts (1..500).to_a.shuffle.join(' ')\"); ./push_swap $LIST | wc -l\n```\n\n### Pseudo Random Number Generator\n\n- [https://en.wikipedia.org/wiki/Linear-feedback_shift_register](https://en.wikipedia.org/wiki/Linear-feedback_shift_register)\n- [https://stackoverflow.com/questions/7602919/how-do-i-generate-random-numbers-without-rand-function](https://stackoverflow.com/questions/7602919/how-do-i-generate-random-numbers-without-rand-function)\n- [https://www.quora.com/How-do-I-generate-random-numbers-in-certain-range-without-using-rand-function-in-C](https://www.quora.com/How-do-I-generate-random-numbers-in-certain-range-without-using-rand-function-in-C)\n\n### `scp`\n\n- [https://stackoverflow.com/questions/11304895/how-do-i-copy-a-folder-from-remote-to-local-using-scp](https://stackoverflow.com/questions/11304895/how-do-i-copy-a-folder-from-remote-to-local-using-scp)\n\n```bash\ncheat scp\nscp -r -P 31280 coder@codeserver.42sp.org.br:~/path/to/folder ~/path/to/destination\n```\n\n### `lalloc` - Listed Memory Allocation\n\nA linked list in the control structure with all the allocated memory pointers.\nThe interface function `ft_lalloc` allocates memory and adds the pointer to the list.\nThe interface function `ft_free_lalloc` frees all pointers and the list.\n\n### Git `submodule`\n\n- `git clone --recurse-submodule REMOTE_REPO`\n- `git submodule add REMOTE_REPO PATH`\n- `git submodule foreach git pull`\n- `git submodule update --init --recursive`\n- [https://stackoverflow.com/questions/33714063/how-to-update-submodules-in-git](https://stackoverflow.com/questions/33714063/how-to-update-submodules-in-git)\n- [https://stackoverflow.com/questions/59271919/how-to-clone-public-submodule-in-github-actions](https://stackoverflow.com/questions/59271919/how-to-clone-public-submodule-in-github-actions)\n- [https://stackoverflow.com/questions/50254184/git-submodule-and-fetch](https://stackoverflow.com/questions/50254184/git-submodule-and-fetch)\n- [https://www.w3docs.com/snippets/git/how-to-add-a-submodule-in-git.html](https://www.w3docs.com/snippets/git/how-to-add-a-submodule-in-git.html)\n- [https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule#1260982](https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule#1260982)\n- [https://stackoverflow.com/questions/2006172/git-how-to-reset-a-remote-git-repository-to-remove-all-commits](https://stackoverflow.com/questions/2006172/git-how-to-reset-a-remote-git-repository-to-remove-all-commits)\n\n### Git Quirks\n\n- [https://stackoverflow.com/questions/1125476/retrieve-a-single-file-from-a-repository](https://stackoverflow.com/questions/1125476/retrieve-a-single-file-from-a-repository)\n\n### GDB Quirks\n\n- [https://github.com/diegopatas/42-cheatsheet/blob/main/GDB_cheatsheet.md](https://github.com/diegopatas/42-cheatsheet/blob/main/GDB_cheatsheet.md)\n\n### VSCode\n\n- [https://code.visualstudio.com/docs/editor/debugging](https://code.visualstudio.com/docs/editor/debugging)\n- [https://code.visualstudio.com/docs/editor/tasks](https://code.visualstudio.com/docs/editor/tasks)\n\n### C quirks\n\n- [https://stackoverflow.com/questions/48687315/warning-ignoring-return-value-of-write-declared-with-attribute-warn-unused-r](https://stackoverflow.com/questions/48687315/warning-ignoring-return-value-of-write-declared-with-attribute-warn-unused-r)\n- [https://stackoverflow.com/questions/36645660/why-cant-i-cast-a-function-pointer-to-void](https://stackoverflow.com/questions/36645660/why-cant-i-cast-a-function-pointer-to-void)\n- [https://stackoverflow.com/questions/689677/why-cast-unused-return-values-to-void](https://stackoverflow.com/questions/689677/why-cast-unused-return-values-to-void)\n- [https://www.internalpointers.com/post/understanding-meaning-lvalues-and-rvalues-c](https://www.internalpointers.com/post/understanding-meaning-lvalues-and-rvalues-c)\n- [https://stackoverflow.com/questions/3530771/passing-variable-arguments-to-another-function-that-accepts-a-variable-argument](https://stackoverflow.com/questions/3530771/passing-variable-arguments-to-another-function-that-accepts-a-variable-argument)\n- [https://en.wikipedia.org/wiki/Stack_overflow](https://en.wikipedia.org/wiki/Stack_overflow)\n\n### C Function Pointers\n\n- [https://stackoverflow.com/questions/25671410/function-that-returns-a-function-pointer-syntax](https://stackoverflow.com/questions/25671410/function-that-returns-a-function-pointer-syntax)\n\n```c\nfloat (*function_name(unsigned id))(float value) {}\n\nvoid (*function_name(char *operation))(void) {}\ntypedef void\t(*t_name_cb)(void);\nt_name_cb\tfunction_name(char *operation)\n```\n\n### Make Quirks\n\n- [https://stackoverflow.com/questions/2019989/how-to-assign-the-output-of-a-command-to-a-makefile-variable](https://stackoverflow.com/questions/2019989/how-to-assign-the-output-of-a-command-to-a-makefile-variable)\n\n### Bash Quirks\n\n- [https://stackoverflow.com/questions/11027679/capture-stdout-and-stderr-into-different-variables](https://stackoverflow.com/questions/11027679/capture-stdout-and-stderr-into-different-variables)\n- [https://unix.stackexchange.com/questions/444935/execute-command-and-store-everything-to-variable-in-bash](https://unix.stackexchange.com/questions/444935/execute-command-and-store-everything-to-variable-in-bash)\n- [https://www.cyberciti.biz/faq/bash-for-loop/](https://www.cyberciti.biz/faq/bash-for-loop/)\n- [https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash](https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash)\n- [https://stackoverflow.com/questions/525592/find-and-replace-inside-a-text-file-from-a-bash-command](https://stackoverflow.com/questions/525592/find-and-replace-inside-a-text-file-from-a-bash-command)\n\n### Send `EOF` to `STDIN`\n\n- [https://unix.stackexchange.com/questions/16333/how-to-signal-the-end-of-stdin-input](https://unix.stackexchange.com/questions/16333/how-to-signal-the-end-of-stdin-input)\n- `Ctrl+D`\n\n### SSH Key Fingerprint\n\n- [https://stackoverflow.com/questions/9607295/calculate-rsa-key-fingerprint](https://stackoverflow.com/questions/9607295/calculate-rsa-key-fingerprint)\n\n### Videos\n\n- [https://invidious.weblibre.org/watch?v=Ee0HzlnIYWQ\u0026ab_channel=freeCodeCamp.org](https://invidious.weblibre.org/watch?v=Ee0HzlnIYWQ\u0026ab_channel=freeCodeCamp.org)\n- [https://invidious.weblibre.org/watch?v=kPRA0W1kECg](https://invidious.weblibre.org/watch?v=kPRA0W1kECg)\n- [https://invidious.weblibre.org/watch?v=Lb_1R6JGD6o\u0026ab_channel=ComputaçãocomProf.Foleis](https://invidious.weblibre.org/watch?v=Lb_1R6JGD6o\u0026ab_channel=Computa%C3%A7%C3%A3ocomProf.Foleis)\n- [https://invidious.weblibre.org/watch?v=t5NszbIerYc](https://invidious.weblibre.org/watch?v=t5NszbIerYc)\n- [https://invidious.weblibre.org/watch?v=XaqR3G_NVoo\u0026t=6s](https://invidious.weblibre.org/watch?v=XaqR3G_NVoo\u0026t=6s)\n- [https://invidious.weblibre.org/watch?v=lyZQPjUT5B4](https://invidious.weblibre.org/watch?v=lyZQPjUT5B4)\n- [https://invidious.weblibre.org/watch?v=7KW59UO55TQ](https://invidious.weblibre.org/watch?v=7KW59UO55TQ)\n- https://www.youtube.com/watch?v=ZZuD6iUe3Pc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fft_push_swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibrity%2Fft_push_swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrity%2Fft_push_swap/lists"}