filunieto / push_swap_git

Proyect push swap 42

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

42PushSwap

This project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate varioustypes of algorithms and choose the one (of many) most appropriate solution for anoptimized data sorting.

Number of approaches in movements

  • 2n: 2 Moves
  • 3n: Between 2 and 3 movements
  • 5n: Between 7 and 12 movements
  • 100n: Between 500 and 700 movements
  • ./500n: Between 5100 and 5500 movements



For further information about 42cursus and its projects, please refer to 42cursus repo.

Push_swap

Prerequisites

This project is for Mac OS.

Installation

  • git clone https://github.com/filunieto/push_swap_git.git this repository
  • Enter in the cloned folder (per default)cd push_swap_git

Running

  • make

  • Run program with ./push_swap 3 5 7

Run push_swap with ramdons autogenerated numbers:

ARG=`ruby -e "puts (-0..100).to_a.shuffle.join(' ')"`; ./push_swap $ARG

Count the operations:

ARG=`ruby -e "puts (0..100).to_a.shuffle.join(' ')"`; ./push_swap $ARG | wc -l

Useful Links

Visualizer

move <pyviz.py> to main folder To execute it:

python3 pyviz.py `ruby -e "puts (-0..100).to_a.shuffle.join(' ')"`

Tester

Rename checker_mac to checker. Move <genstack.pl> to main folder.

chmod 744 genstack.pl
chmod 744 checker

To execute it:

bash push_swap_tester/tester.sh . 0-10 5

Sanitize

Add -g in gcc command.

-fsanitize=leak
-fsanitize=address

Print traces

Add in header file this define:

# define PRINT_HERE() (printf("file: %s, line: %d\n", __FILE__, __LINE__))

And used it from any part of your program

PRINT_HERE();

About

Proyect push swap 42


Languages

Language:C 96.4%Language:Makefile 3.6%