Skip to content

rafaelabdm/push_swap

Repository files navigation

✏️ push_swap


O propósito desse projeto é organizar uma pilha de ints com apenas duas stacks e movimentos limitados. 😊
The purpose of this project is to sort a int stack with only two stacks and limited moves. 😊

GitHub code size in bytes Code language count GitHub top language GitHub last commit


💻 About the project

Push it!

Esse projeto fará com que você organize informação em uma pilha, com movimentos limitados, usando a menor quantidade de ações possível.
Para obter sucesso você deve manipular vários tipos de algoritmos e escolher a solução mais apropriada para uma organização de dados
mais otimizada.

This project will make you sort data on a stack, with a limited set of instructions,using the lowest possible number of actions.
To succeed you’ll have to manipulate varioustypes of algorithms and choose the most appropriate solution (out of many) for an
optimized data sorting.

📱 Rules of the instructions:

The goal is to sort in ascending order, numbers into stack a. You can only use 2 stacks (a and b).

You have the following operations at your disposal:

• SA (SWAP A): Swap the first 2 elements at the top of stack a - do nothing if there is only one or no elements.
• SB (SWAP B): Swap the first 2 elements at the top of stack b - do nothing if there is only one or no elements.
• SS : sa and sb at the same time.
• 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.
• 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.
• RA (ROTATE A): Shift up all elements of stack a by 1 - the first element becomes the last one.
• RB (ROTATE B): Shift up all elements of stack b by 1 - the first element becomes the last one.
• RR : ra and rb at the same time.
• RRA (REVERSE ROTATE A): Shift down all elements of stack a by 1 - the last element becomes the first one.
• RRB (REVERSE ROTATE B): Shift down all elements of stack b by 1 - the last element becomes the first one.
• RRR : rra and rrb at the same time.

💻 COMO USAR:

>$ make

>$ ./push_swap ~numbers you want to sort -> top to bottom~
EXEMPLE: >$ ./push_swap 5 3 2 4 1

About

Esse projeto consiste em fazer um algoritmo organizacional eficiente, mas com movimentos limitados // This proect is about creating a sorting algorithm, but with limited moves

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors