Skip to content

TheJocker94/ft_push_swap_42

Repository files navigation

Push_Swap42

Ordering a Stack with limited operations available.

Push_swap

This project focuses on data sorting on a stack using a limited set of instructions, aiming to achieve the sort with the minimum possible number of operations.

Table of Contents

  1. Introduction
  2. Objectives
  3. Common Instructions
  4. Mandatory Part
  5. Bonus Part

Introduction

Push swap project focuses on creating a simple, straightforward sorting algorithm that uses two stacks and a set of instructions to manipulate both stacks. The primary goal is to write a program in C called push_swap, which calculates and displays the smallest program, composed of push_swap language instructions, to sort the integers received as arguments.

Objectives

Writing a sorting algorithm is a critical step for a developer as it introduces the concept of complexity. The key learning objectives of this project are rigor, the use of C, and the application of basic algorithms with a focus on complexity.

Common Instructions

  • Project must be written in C.
  • It should comply with the Norm.
  • It should not quit unexpectedly (segmentation fault, bus error, double free, etc).
  • All heap allocated memory space must be properly freed when necessary.
  • Submission must include a Makefile to compile source files to the required output.
  • If the project allows libft, its sources and associated Makefile should be copied in a libft folder.

Mandatory Part

The project involves two stacks named a and b, and a set of instructions to manipulate both stacks.

The goal is to sort the integers into stack a in ascending order using operations like swap, push, rotate and reverse rotate.

The program named push_swap should take stack a as a list of integers and display the smallest list of instructions possible to sort the stack.

Bonus Part

Create a checker program to verify whether the list of instructions generated by the push_swap program actually sorts the stack properly.

The checker program takes stack a as a list of integers, waits and reads instructions on the standard input, and executes them on the stack.

If the stack a is sorted after executing the instructions and stack b is empty, the checker should display "OK". In any other case, it should display "KO".

About

Ordering a Stack with limited operations available.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published