https://github.com/achrafelkhnissi/push_swap
This project is about sorting data on a stack with a limited set of instructions, using the lowest possible number of actions.
https://github.com/achrafelkhnissi/push_swap
1337 1337school 42 42born2code 42cursus 42projects 42school
Last synced: 7 months ago
JSON representation
This project is about sorting data on a stack with a limited set of instructions, using the lowest possible number of actions.
- Host: GitHub
- URL: https://github.com/achrafelkhnissi/push_swap
- Owner: achrafelkhnissi
- Created: 2022-06-02T17:04:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T02:14:13.000Z (about 3 years ago)
- Last Synced: 2025-01-17T07:47:25.131Z (9 months ago)
- Topics: 1337, 1337school, 42, 42born2code, 42cursus, 42projects, 42school
- Language: C
- Homepage: https://www.linkedin.com/in/achrafelkhnissi/
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
42cursus' push_swap
Development repo for 42cursus' push_swap project
For further information about 42cursus and its projects, please refer to 42cursus repo.
Summary
·
Resources
·
Rules
·
Operations---
## SUMMARY
The project will make you sort data on a stack, with a limited set of instructions, using the lowest number of actions. To succeed you will have to manipulate various types of algorithms and choose the most appropriate solution for an optimized data sorting.## RULES
- The game is composed of 2 stacks named __A__ and __B__.
- To start with:
- A contains a random number of either positive or negative numbers without any duplicates.
- B is empty.
- The goal is to sort in ascending order numbers into stack __A__.
- To do this, you have the following operations.## OPERATIONS
* [`sa`](srcs/operations/sa_swap_a.c) - swap __a__: swap the first 2 elements at the top of stack __a__. (do nothing if there is only one or no elements).
* [`sb`](srcs/operations/sb_swap_b.c) - swap __b__: swap the first 2 elements at the top of stack __b__. (do nothing if there is only one or no elements).
* [`ss`](srcs/operations/ss_sa_sb.c) - ss: swap __a__ and swap __b__ at the same time.
* [`pa`](srcs/operations/pa_push_a.c) - push __a__: take the first element at the top of __b__ and put it at top of __a__. (do nothing if __b__ is empty).
* [`pb`](srcs/operations/pb_push_b.c) - push __b__: take the first element at the top of __a__ an dput it at top of __b__. (do nothing if __a__ is empty).
* [`ra`](srcs/operations/ra_rotate_a.c) - rotate __a__: shift up all elements of stack __a__ by 1. the first element becomes the last one.
* [`rb`](srcs/operations/rb_rotate_b.c) - rotate __b__: shift up all elements of stack __b__ by 1. the first element becomes the last one.
* [`rr`](srcs/operations/rr_ra_rb.c) - rr: rotate __a__ and rotate __b__ at the same time.
* [`rra`](srcs/operations/rra_reverse_rotate_a.c) - reverse rotate __a__: shift down all elements of stack __a__ by 1. the last element becomes the first one.
* [`rrb`](srcs/operations/rrb_reverse_rotate_b.c) - reverse rotate __b__: shift down all elements of stack __b__ by 1. the last element beoomes the first one.
* [`rrr`](srcs/operations/rrr_rra_rrb.c) - rrr: reverse rotate __a__ and reverse rotate __b__ at the same time.## TESTING
- Change the `` with any number u want!
```bash
make test ARG=
```## RESOURCES
- [medium - understanding push_swap](https://medium.com/@jamierobertdawson/push-swap-the-least-amount-of-moves-with-two-stacks-d1e76a71789a)
- [medium - Understanding Sorting Algorithms](https://medium.com/jl-codes/understanding-sorting-algorithms-af6222995c8)
- [youtube - push_swap](https://www.youtube.com/watch?v=7KW59UO55TQ)
- [push_swap visualizer](https://2g2uk.csb.app)