Go to file
Camille Chauvet ac54a8f977 add: readme
2023-03-27 16:20:38 +02:00
ft_atoi.c c fini bro 2022-12-11 17:56:20 +01:00
ft_bitlen.c presque 2022-12-06 17:35:45 +01:00
ft_bozo_sort.c ca marche trop bien 2022-12-11 15:49:45 +01:00
ft_get_max.c presque 2022-12-06 17:35:45 +01:00
ft_is_sorted.c ca marche 2022-12-09 19:13:15 +01:00
ft_isnum.c fix 2023-01-19 17:30:22 +01:00
ft_p.c ca marche avec print 2022-12-07 14:19:16 +01:00
ft_putstr.c ca marche 2022-12-09 19:13:15 +01:00
ft_r.c work but bozo sort not work 2022-12-09 15:22:02 +01:00
ft_radix.c work but bozo sort not work 2022-12-09 15:22:02 +01:00
ft_rr.c ca marche 2022-12-09 19:13:15 +01:00
ft_s.c normed 2022-12-09 19:17:57 +01:00
ft_sort.c ca marche trop bien 2022-12-11 15:49:45 +01:00
ft_split.c ca marche trop bien 2022-12-11 15:49:45 +01:00
ft_strlen.c presque 2022-12-06 17:35:45 +01:00
ft_swap.c g vire le bit shift c mieu 2022-12-01 17:15:17 +01:00
ft_tablen.c g vire le bit shift c mieu 2022-12-01 17:15:17 +01:00
main.c c fini bro 2022-12-11 17:56:20 +01:00
Makefile remove gdb flag 2022-12-11 19:16:18 +01:00
pushswap.h c fini bro 2022-12-11 17:56:20 +01:00
README.md add: readme 2023-03-27 16:20:38 +02:00
subject.pdf add: readme 2023-03-27 16:20:38 +02:00

Pushswap

This is my implementation of the Pushswap project for the 42 school, using the radix sort algorithm.

Description

Pushswap is a sorting algorithm that sorts a list of integers using two stacks and a set of operations. The goal of the project is to implement the Pushswap algorithm in C and optimize the algorithm to sort the list using the minimum number of operations possible.

In this implementation, I used the radix sort algorithm, which sorts the list by comparing each digit of the integers in the list, from right to left. The algorithm sorts the integers by "bucketing" them based on their current digit value, and then repeating this process for each subsequent digit.

The project aims to develop students' problem-solving and algorithmic thinking skills, as well as their ability to optimize code for performance.

Usage

To use the program, first compile the push_swap executable by running make in the root directory of the project.

Then, run the program with a list of integers as arguments. For example: ./push_swap 4 67 -10 5.

The program will display a list of operations to sort the list, and the number of operations required.

Algorithm Overview

radix

The algorithm consists of the following steps:

  1. replace the value of the number by the index of the number
  2. put the number on the stack B if the n bit equal 0
  3. do the same for n + 1 while the stack was not sorted

Optimization

To optimize the algorithm, I used a combination of heuristics and algorithms, such as:

  • Minimizing the number of operations by considering special cases, such as sorted or reverse-sorted lists

Through experimentation and testing, I was able to significantly reduce the number of operations required to sort the list.

Resources

  • The project subject
  • The C library documentation for the standard library functions used in the program

Authors

This project was created by Camille CHAUVET. If you have any questions or suggestions, feel free to contact me.