From 9963c751d8e3288d5d5a4a91d73603ac42006216 Mon Sep 17 00:00:00 2001 From: djonker Date: Sat, 11 Mar 2023 04:22:12 +0100 Subject: [PATCH] readmeupdate --- Readme.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 3d50fb5..4aa3be9 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,54 @@ -Todo - Improve 5 number algorhythm +# Project Name +Push Swap is a 2 stack sorting algoritm, The goal is to sort the input in as few moves as possible\ +I wrote my own algoritm which is a combination of quick sort and bubble sort as radix is very bad with only 2 stacks\ +The following is a list of the moves we are allowed to make -Tester - catch fsanitize signals - create line that replaces -Wextra with "-g -fsanitize=address" - check for -Wall -Werror -Wextra +| Move | Description | +| -- | ------ | +| pa | Pushes the top number from stack B to stack A | +| pb | Pushes the top number from stack A to stack B | +| sa | Swaps the top 2 numbers in stack A | +| sb | Swaps the top 2 numbers in stack B | +| ss | Swaps the top 2 numbers in stack A and in Stack B | +| ra | Rotates Stack A moves all items forward so the last item becomes the first | +| rb | Rotates Stack B moves all items forward so the last item becomes the first | +| rr | Rotates Both stacks moves all items forward, so the last item becomes the first | +| rra | Reverse Rotates Stack A moves all items backwards, so the first item becomes the last | +| rrb | Reverse Rotates Stack B moves all items backwards, so the first item becomes the last | +| rrr | Reverse Rotates Both stacks moves all items backwards, so the first item becomes the last | + +--- +## Improvements +#### Improve 5 numbers algoritm +simply hardcode all possibilities with 5 numbers or less +#### Improve more than 30 algoritm +Gotta figure this out to always stay under the goals + +--- +## Usage +#### Sorter +1. Simply clone or download the repository +2. Run `make` in the cloned directory +3. Start the program with `./push_swap [numbers seperated by space]` +4. It will return the list of moves to sort the stack +#### Checker +1. Simply clone or download the repository +2. Run `make bonus` in the cloned directory +3. Start the program with `./checker [numbers seperated by space]` +4. You will have to input moves seperated by a return and when you are done press CTRL + D +5. It will return a OK or a KO. +#### Both +1. You can also run both programs with `./push_swap [numbers] | ./checker [same numbers]` + +--- +## Tester +- add valgrind to tester +- check for -Wall -Werror -Wextra + +#### Usage +1. Download test.sh to your push swap directory +2. Make the file executable `chmod +x test.sh` +3. Run `./test.sh` to start the test + +--- +[This project is part of the studies at 42](https://42.fr/en/homepage/)