GithubHelp home page GithubHelp logo

ehabelasam / push_swap_42 Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 426 KB

the "Push_Swap" project is a challenging exercise that involves sorting data on a stack using a limited set of instructions.

Makefile 3.69% C 96.31%
pushswap pushswap-42 radix-sort sort sorting sorting-algorithms libft libft42 42

push_swap_42's Introduction

Push_Swap

Project Overview

The "Push_Swap" project is a challenging exercise that involves sorting data on a stack using a limited set of instructions. The objective is to sort the data using the smallest number of actions possible. This requires manipulating various types of algorithms to choose the most optimized solution for data sorting. Installation

To use this project, clone the repository and compile the files using Make.

git clone [email protected]:EhabElasam/push_swap_42.git

cd push_swap

make

Features

main(): Initializes and starts the sorting process, processes input arguments, initializes data structures, and outputs the sequence of operations.

validate_input(): Validates that all inputs are integers and checks for duplicates.

init_stacks(): Initializes the stacks with input values.

sort_stack(): Contains the logic to choose and execute the sorting algorithm using stack operations.

Stack Operations: Swap: swap_a(), swap_b(), swap_both() Push: push_a(), push_b() Rotate: rotate_a(), rotate_b(), rotate_both() Reverse Rotate: reverse_rotate_a(), reverse_rotate_b(), reverse_rotate_both()

print_operations(): Outputs the operations performed to sort the stack.

cleanup(): Frees up resources and allocated memory to prevent memory leaks.

Error Handling: handle_error() manages and reports errors during program execution.

Usage

After installation, you can run the program as follows:

./push_swap <sequence of numbers>

Example:

./push_swap 4 67 3 87 23

The program will output a list of instructions needed to sort the sequence of numbers.

Contributing

Contributions to the project are welcome. You can report bugs, submit pull requests, or suggest improvement

push_swap_42's People

Contributors

ehabelasam avatar

Stargazers

huaydin avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.