Giter Site home page Giter Site logo

push_swap's Introduction

pushswap img

push_swap

A project to sort a stack using a limited set of operations in C.

This project implements a sorting algorithm for a stack, using only a specified set of operations, with the goal of doing so in the fewest moves possible. It showcases algorithmic thinking, efficient stack manipulation, and the ability to work with constraints.

Structure

shared/

The shared directory contains utility functions and data structures shared across different parts of the project:

  • stack_operations.c: Implements basic operations like sa, sb, ss, pa, pb, ra, rb, rr, rra, rrb, and rrr to manipulate the stacks.
  • stack_utils.c: Includes helper functions for stack management, such as initializing stacks, checking sorted status, and error handling.
  • input_parsing.c: Functions for parsing and validating the input, ensuring correct stack initialization.

project/

The project directory contains the core algorithm implementation:

  • push_swap.c: The main function that drives the sorting process, determining the optimal sequence of operations.
  • sorting_algorithms.c: Implements various sorting techniques depending on the size of the stack, including simple sorting for small stacks and more complex algorithms for larger ones.
  • move_optimizer.c: Contains logic to optimize the sequence of operations, minimizing the total number of moves required.

push_swap.h

The header file declares the prototypes for all functions and defines necessary macros, ensuring proper linkage between the shared utilities and the core algorithm.

Makefile

The Makefile automates the build process, compiling all source files and linking them to create the final executable.

Features

  • Stack Sorting: Efficiently sorts a stack of integers with a limited set of operations.
  • Input Validation: Robust input parsing and error handling to ensure correct initial conditions.
  • Operation Optimization: Minimizes the number of moves required to sort the stack.

Usage

To compile the project, run:

make

push_swap's People

Contributors

ebejay95 avatar

Stargazers

Silva#5525 avatar  avatar ~Yusupov____ 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.