The push_swap program is a project from école 42. There are stickt rules to follow.
Sort the stack A in an ascending order numbers(from smallest to largest) with the least amount of moves possible.
During the evaluation process, the number of instructions found by your program will be compared against a limit: the maximum number of operations tolerated.
You have some limitations: you only have a stack B you can use.
Also, there's some specific moves you can do:
- 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.
- Must be according to the Norm;
- Must be written in the C language;
- Must have a Makefile that compiles, delete and recompile the project;
- In case of error, it must display "Error" followed by a ’\n’ on the standard error. Errors include for example: some arguments aren’t integers, some arguments are bigger than an integer and/or there are duplicates
- External functions that are allowed: read, write, malloc, free, exit