https://github.com/zainabdnaya/push_swap_42
sort data on a stack, with a limited set of instructions, using the lowest possible number of actions
https://github.com/zainabdnaya/push_swap_42
42 sort sort-data stacks swap
Last synced: about 1 year ago
JSON representation
sort data on a stack, with a limited set of instructions, using the lowest possible number of actions
- Host: GitHub
- URL: https://github.com/zainabdnaya/push_swap_42
- Owner: zainabdnaya
- Created: 2021-04-02T11:17:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-17T08:41:07.000Z (over 4 years ago)
- Last Synced: 2025-04-12T06:49:56.634Z (about 1 year ago)
- Topics: 42, sort, sort-data, stacks, swap
- Language: C
- Homepage:
- Size: 3.05 MB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# push_swap
sort data on a stack, with a limited set of instructions, using the lowest possible number of actions
## Explanation about The algorithm that I use :
algorithm push_swap
## To Test
Try to use : ./push_swap -h "this command will show what to do "
## Concept of this Project ##
The idea is simple, You have two stacks called Stack A and Stack B.
Stack A is given a random list of unorganized numbers.
You must take the random list of numbers in Stack A and sort them so that Stack A is organized from smallest to largest.
There are only a few moves you’re allowed to used to manipulate the stacks that we’re going to call “Actions”.
The main goal of this project is to organize Stack A in as few actions as possible.
## MOVES ##
the moves are named: sa, sb, ss, ra, rb, rr, rra, rrb, rrr, pa, pb.
I use Double linked list to implement these moves :
## sa || sb :arrows_clockwise: ##
-swap 2 first element
## :arrow_heading_up: ra || rb :arrow_right_hook: ##
-put the first element last,and all elemnt go UP by one

## :arrow_heading_down: rra || rrb :arrows_counterclockwise: ##
-put the last element First, so all elements go DOWN by ine element

## pa || pb :arrow_right: ##
-take the first element at the top of a stack and put it at the top of other_stack.

## Checker:
-Thanks to the checker program, you will be able to check if the
list of instructions you’ll generate with the program push_swap is
actually sorting the stack properly.
## This is how much instructions the algorithm Do with 100 random number

