Skip to content

Project 7: Push Swap - Seventh project for the formation of software engineers at school 42 São Paulo.

Notifications You must be signed in to change notification settings

Vinicius-Santoro/42-formation-lvl2-7.push-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42-formation-lvl2-7.push-swap

Project 7: Push Swap - Seventh project for the formation of software engineers at school 42 São Paulo.

  • This project aim to sort data on a stack, with a limited set of instructions, using the lowest possible number of operations.

This project was like this:

push_swap

The operations we can use are:

Operation Description
sa (swap a) Swap the first 2 elements at the top of stack a
sb (swap b) Swap the first 2 elements at the top of stack b
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
rb (rotate b) Shift up all elements of stack b by 1
rr ra and rb at the same time
rra (reverse rotate a) Unsigned hexadecimal integer (uppercase)
rrb (reverse rotate b) Shift down all elements of stack b by 1
rrr rra and rrb at the same time.

How to test it

To test, you should run the Make all command

make all

Now compile the executable file generated by the makefile and add the parameters you want. For example:

./push_swap 42 142 9123 -123 -254231278 -10470 12748 -15027 -17306 1864

Examples

We can check stacks A and B. On the right, we can see the operation that was used.

Example 1) Sorting with 5 random and distinct integers:

sorting-5

Example 2) Sorting with 100 random and distinct integers:

42.sp.mp4

Example 3) Sorting with 1000 random and distinct integers:

42.sp.mp4

About

Project 7: Push Swap - Seventh project for the formation of software engineers at school 42 São Paulo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published