Skip to content

This project is about sorting data on a stack with a limited set of instructions, using the lowest possible number of actions.

Notifications You must be signed in to change notification settings

achrafelkhnissi/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42cursus' push_swap

Development repo for 42cursus' push_swap project
For further information about 42cursus and its projects, please refer to 42cursus repo.


SUMMARY

The project will make you sort data on a stack, with a limited set of instructions, using the lowest number of actions. To succeed you will have to manipulate various types of algorithms and choose the most appropriate solution for an optimized data sorting.

RULES

  • The game is composed of 2 stacks named A and B.
  • To start with:
    • A contains a random number of either positive or negative numbers without any duplicates.
    • B is empty.
  • The goal is to sort in ascending order numbers into stack A.
  • To do this, you have the following operations.

OPERATIONS

  • 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 - ss: swap a and swap b at the same time.
  • pa - push a: take the first element at the top of b and put it at top of a. (do nothing if b is empty).
  • pb - push b: take the first element at the top of a an dput it at 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 - rr: rotate a and rotate b 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 beoomes the first one.
  • rrr - rrr: reverse rotate a and reverse rotate b at the same time.

TESTING

  • Change the <number_of_random_args> with any number u want!
make test ARG=<number_or_random_args>

RESOURCES

About

This project is about sorting data on a stack with a limited set of instructions, using the lowest possible number of actions.

Topics

Resources

Stars

Watchers

Forks