Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/medidbella/push_swap

This project involves sorting data on a stack, with a limited set of instructions, and the smallest number of moves.
https://github.com/medidbella/push_swap

sorting-algorithms stacks

Last synced: about 1 month ago
JSON representation

This project involves sorting data on a stack, with a limited set of instructions, and the smallest number of moves.

Awesome Lists containing this project

README

        

---------------------------------------------------_PUSH-SWAP ?_-------------------------------------------------------

This project involves sorting data on a stack, with a limited set of instructions, and the smallest number of moves.

you have the right to use only two stacks and only theis instructoins :

SA (swap a): Swap the first 2 elements at the top of stack a. Do nothing if there is only one or no element.

SB (swap b): Swap the first 2 elements at the top of stack b. Do nothing if there is only one or no element.

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.

PB (push b): Take the first element at the top of a and put it at the top of b.

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.

the project will only print the minimum number of instructions to sort the stack 'a' in ascending order

-----------------------------------------------------------------------------------------------------------------------