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

https://github.com/ugolinolle/push_swap

📤 • Efficient stack sorting using limited operations in push_swap.
https://github.com/ugolinolle/push_swap

42 push-swap push-swap42

Last synced: 2 months ago
JSON representation

📤 • Efficient stack sorting using limited operations in push_swap.

Awesome Lists containing this project

README

          

# Push_swap


Push_swap

## 📝・Description

Push_swap is a sorting algorithm project that challenges you to sort a stack of integers using a limited set of operations. The goal is to implement an efficient sorting algorithm that uses the fewest possible moves to sort the stack.

## 🎯・Objectives

- Implement a sorting algorithm using two stacks
- Minimize the number of operations used to sort the stack
- Understand and apply algorithm complexity concepts
- Improve problem-solving skills and C programming proficiency

## 🛠・Usage

### Compilation

```bash
make
```

### Running the program

```bash
./push_swap
```

### Example:
```bash
./push_swap 2 1 3 6 5 8
```

## 🔍・Available Operations

- sa: swap the first two elements of stack a
- sb: swap the first two elements of stack b
- ss: perform sa and sb simultaneously
- pa: push the top element from stack b to stack a
- pb: push the top element from stack a to stack b
- ra: rotate stack a (first element becomes last)
- rb: rotate stack b (first element becomes last)
- rr: perform ra and rb simultaneously
- rra: reverse rotate stack a (last element becomes first)
- rrb: reverse rotate stack b (last element becomes first)
- rrr: perform rra and rrb simultaneously

## 📊・Performance Benchmarks

- For 100 random numbers: < 700 operations
- For 500 random numbers: < 5500 operations

## 🧑‍🤝‍🧑・Contributing

Contributions to this project are welcome. If you find any issues or want to improve the code, please feel free to open a pull request or issue.

## 📑・License

This project is licensed under the [MIT License](https://github.com/UgolinOlle/push_swap/blob/master/LICENSE) - see the LICENSE file for details.

## 📩・Contact

If you have any questions or would like to collaborate, please do not hesitate to contact me at [email](mailto:hello@ugolin-olle.com) or [LinkedIn](https://linkedin.com/in/ugolin-olle)