From 6a71a349908d270cb0ffc28b38c5da66985e9619 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Wed, 4 Dec 2019 12:35:54 +0000 Subject: [PATCH 1/8] push_swap ReadMe --- subjects/push_swap.en.md | 152 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 subjects/push_swap.en.md diff --git a/subjects/push_swap.en.md b/subjects/push_swap.en.md new file mode 100644 index 00000000..d10d86f3 --- /dev/null +++ b/subjects/push_swap.en.md @@ -0,0 +1,152 @@ +## push_swap + +### Objectives + +Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of int values, two stacks (`a` and `b`) and a set of instructions. + +You will have two write 2 programs: + +- **push_swap**, which calculates and displays on the standard output the smallest program using push_swap instruction language that sorts integer arguments received. +- **checker**, which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`. + +As said before, you will have two stacks at your disposal. Your goal is to sort stack `a`, that will contain the int values received, in ascending order, using both stacks and a set of instructions. + +These are the instructions that you can use to sort the stack : + +- `pa` push the top first element of stack `a` to stack `b` +- `pb` push the top first element of stack `b` to stack `a` +- `sa` swap first 2 elements of stack `a` +- `sb` swap first 2 elements of stack `b` +- `ss` execute `sa` and `sb` +- `ra` rotate stack `a` (the first element becomes the last) +- `rb` rotate stack `b` +- `rr`execute `ra` and `rb` +- `rra` reverse rotate `a` (the last element becomes the first) +- `rrb` reverse rotate `b` +- `rrr` execute `rra` and `rrb` + +#### Example: + +```console +--------------------------------------- +Init a and b : +2 +1 +3 +6 +8 +5 += = +a b +--------------------------------------- +Exec sa : +1 +2 +3 +6 +8 +5 += = +a b +--------------------------------------- +Exec pb pb pb : +6 3 +8 2 +5 1 += = +a b +--------------------------------------- +Exec ra rb (equivalent to rr): +5 2 +8 1 +6 3 += = +a b +--------------------------------------- +Exec rra and rrb (equivalent to rrr): +6 3 +5 2 +8 1 += = +a b +--------------------------------------- +Exec sa: +5 3 +6 2 +5 1 += = +a b +--------------------------------------- +Exec pa pa pa: +1 +2 +3 +5 +6 +8 += = +a b +--------------------------------------- +``` + +This project will help you learn about : + +- the use of basic algorithms +- the use of sorting algorithms +- the use of stacks + +#### The push_swap program + +- You have to write a program named push_swap, which will receive as an argument the stack a formated as a list of integers. The first integer should be at the top of the stack. +- The program must display the smallest list of instructions possible to sort the stack `a`, with the smallest number being at the top. +- Instructions must be separated by a ’\n’ and nothing else. +- The goal is to sort the stack with the minimum possible number of operations. +- In case of error, you must display Error followed by a ’\n’ on the standard error. Errors include for example: some arguments aren’t integers and/or there are duplicates. + +```console +$>./push_swap 2 1 3 6 5 8 +sa +pb +pb +pb +sa +pa +pa +pa +$>./push_swap 0 one 2 3 +Error +$> +``` + +#### The checker program + +- You have to write a program named checker, which will get as an argument the stack a formatted as a list of integers. The first argument should be at the top of the stack (be careful about the order). If no argument is given checker stops and displays nothing. +- Checker will then read instructions on the standard input, each instruction will be followed by ’\n’. Once all the instructions have been read, checker will execute them on the stack received as an argument. +- If after executing those instructions, stack `a` is actually sorted and `b` is empty, then checker must display "OK" followed by a ’\n’ on the standard output. In every other case, checker must display "KO" followed by a ’\n’ on the standard output. +- In case of error, you must display Error followed by a ’\n’ on the standard error. Errors include for example: some arguments are not integers, there are duplicates, an instruction don’t exist and/or is incorrectly formatted. + +```console +$>./checker 3 2 1 0 +rra +pb +sa +rra +pa +OK +$>./checker 3 2 1 0 +sa +rra +pb +KO +$>./checker 3 2 one 0 +Error +$> +``` + +### Instructions + +- Your project must be written in **Go**. +- The code must respect the [**good practices**](https://github.com/01-edu/public/good-practices.en.md). +- It is recommended that the code should present a **test file**. +- The first executable file must be named **checker** and the second **push_swap**. +- You have to be able to handle the errors. From cb7c184ff719e65b7ed40d3925cff99bac520013 Mon Sep 17 00:00:00 2001 From: lee Date: Mon, 9 Dec 2019 09:45:11 +0000 Subject: [PATCH 2/8] rename and fix on push-swap --- subjects/{push_swap.en.md => push-swap.en.md} | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) rename subjects/{push_swap.en.md => push-swap.en.md} (65%) diff --git a/subjects/push_swap.en.md b/subjects/push-swap.en.md similarity index 65% rename from subjects/push_swap.en.md rename to subjects/push-swap.en.md index d10d86f3..553ee125 100644 --- a/subjects/push_swap.en.md +++ b/subjects/push-swap.en.md @@ -2,30 +2,30 @@ ### Objectives -Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of int values, two stacks (`a` and `b`) and a set of instructions. +Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of `int` values, two stacks (`a` and `b`) and a set of instructions. You will have two write 2 programs: - **push_swap**, which calculates and displays on the standard output the smallest program using push_swap instruction language that sorts integer arguments received. - **checker**, which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`. -As said before, you will have two stacks at your disposal. Your goal is to sort stack `a`, that will contain the int values received, in ascending order, using both stacks and a set of instructions. +As said before, you will have two stacks at your disposal. Your goal is to sort stack `a`, that will contain the `int` values received, in ascending order, using both stacks and a set of instructions. These are the instructions that you can use to sort the stack : -- `pa` push the top first element of stack `a` to stack `b` -- `pb` push the top first element of stack `b` to stack `a` +- `pa` push the top first element of stack `b` to stack `a` +- `pb` push the top first element of stack `a` to stack `b` - `sa` swap first 2 elements of stack `a` - `sb` swap first 2 elements of stack `b` - `ss` execute `sa` and `sb` -- `ra` rotate stack `a` (the first element becomes the last) +- `ra` rotate stack `a` (shift up all elements of stack `a` by 1, the first element becomes the last one) - `rb` rotate stack `b` - `rr`execute `ra` and `rb` -- `rra` reverse rotate `a` (the last element becomes the first) +- `rra` reverse rotate `a` (shift down all elements of stack `a` by 1, the first element becomes the last one) - `rrb` reverse rotate `b` - `rrr` execute `rra` and `rrb` -#### Example: +#### Example ```console --------------------------------------- @@ -57,21 +57,21 @@ Exec pb pb pb : a b --------------------------------------- Exec ra rb (equivalent to rr): -5 2 -8 1 +8 2 +5 1 6 3 = = a b --------------------------------------- Exec rra and rrb (equivalent to rrr): 6 3 -5 2 -8 1 +8 2 +5 1 = = a b --------------------------------------- Exec sa: -5 3 +8 3 6 2 5 1 = = @@ -97,11 +97,11 @@ This project will help you learn about : #### The push_swap program -- You have to write a program named push_swap, which will receive as an argument the stack a formated as a list of integers. The first integer should be at the top of the stack. +- You have to write a program named push_swap, which will receive as an argument the stack a formatted as a list of integers. The first integer should be at the top of the stack. - The program must display the smallest list of instructions possible to sort the stack `a`, with the smallest number being at the top. -- Instructions must be separated by a ’\n’ and nothing else. +- Instructions must be separated by a `\n` and nothing else. - The goal is to sort the stack with the minimum possible number of operations. -- In case of error, you must display Error followed by a ’\n’ on the standard error. Errors include for example: some arguments aren’t integers and/or there are duplicates. +- In case of error, you must display `Error` followed by a `\n` on the standard error. Errors include for example: some arguments aren’t integers and/or there are duplicates. ```console $>./push_swap 2 1 3 6 5 8 @@ -121,9 +121,9 @@ $> #### The checker program - You have to write a program named checker, which will get as an argument the stack a formatted as a list of integers. The first argument should be at the top of the stack (be careful about the order). If no argument is given checker stops and displays nothing. -- Checker will then read instructions on the standard input, each instruction will be followed by ’\n’. Once all the instructions have been read, checker will execute them on the stack received as an argument. -- If after executing those instructions, stack `a` is actually sorted and `b` is empty, then checker must display "OK" followed by a ’\n’ on the standard output. In every other case, checker must display "KO" followed by a ’\n’ on the standard output. -- In case of error, you must display Error followed by a ’\n’ on the standard error. Errors include for example: some arguments are not integers, there are duplicates, an instruction don’t exist and/or is incorrectly formatted. +- Checker will then read instructions on the standard input, each instruction will be followed by `\n`. Once all the instructions have been read, checker will execute them on the stack received as an argument. +- If after executing those instructions, stack `a` is actually sorted and `b` is empty, then checker must display "OK" followed by a `\n` on the standard output. In every other case, checker must display "KO" followed by a `\n` on the standard output. +- In case of error, you must display Error followed by a `\n` on the standard error. Errors include for example: some arguments are not integers, there are duplicates, an instruction don’t exist and/or is incorrectly formatted. ```console $>./checker 3 2 1 0 @@ -149,4 +149,4 @@ $> - The code must respect the [**good practices**](https://github.com/01-edu/public/good-practices.en.md). - It is recommended that the code should present a **test file**. - The first executable file must be named **checker** and the second **push_swap**. -- You have to be able to handle the errors. +- You have to be able to handle the errors. From 60ad96294dfa45391c848165dfcc21fae7ae2241 Mon Sep 17 00:00:00 2001 From: MSilva95 Date: Mon, 9 Dec 2019 09:58:14 +0000 Subject: [PATCH 3/8] push-swap readme --- subjects/push-swap.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subjects/push-swap.en.md b/subjects/push-swap.en.md index 553ee125..d57337a3 100644 --- a/subjects/push-swap.en.md +++ b/subjects/push-swap.en.md @@ -1,4 +1,4 @@ -## push_swap +## push-swap ### Objectives From 1b7a4358438f25711e32b399b2b6e4741e047199 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Fri, 3 Jan 2020 18:08:30 +0000 Subject: [PATCH 4/8] Push Swap README and Questions --- subjects/push-swap/push-swap.audit.en.md | 88 ++++++++++++ subjects/push-swap/push-swap.en.md | 167 +++++++++++++++++++++++ 2 files changed, 255 insertions(+) create mode 100644 subjects/push-swap/push-swap.audit.en.md create mode 100644 subjects/push-swap/push-swap.en.md diff --git a/subjects/push-swap/push-swap.audit.en.md b/subjects/push-swap/push-swap.audit.en.md new file mode 100644 index 00000000..dfb3efcf --- /dev/null +++ b/subjects/push-swap/push-swap.audit.en.md @@ -0,0 +1,88 @@ +#### Functional + +###### Is the solution of the push_swap the simplest possible? (with the fewer instructions) +###### Is the program sorting the stack correctly? + +##### Try to run `"./push_swap"`. +``` + +``` +###### Does it display nothing? +##### Try to run `"./push_swap 2 1 3 6 5 8"`. +``` +sa +pb +pb +pb +sa +pa +pa +pa +``` +###### Does it display the right result as above? +##### Try to run `"./push_swap 0 1 2 3 4 5"`. +``` + +``` +###### Does it display nothing? +##### Try to run `"./push_swap 0 one 2 3"`. +``` +Error +``` +###### Does it display the right result as above? +##### Try to run `"./push_swap 1 2 2 3"`. +``` +Error +``` +###### Does it display the right result as above? +##### Try to run `"./push_swap <5 random numbers>"` with 5 random numbers instead of the tag. +###### Does it displays less than 12 commands? +##### Try to run `"echo -e " " | ./checker "`. +``` + +``` +###### Does it display the right result as above? +##### Try to run `"./checker 0 one 2 3"`. +``` +Error +``` +###### Does it display the right result as above? +##### Try to run `"./checker 1 2 2 3"`. +``` +Error +``` +###### Does it display the right result as above? +##### Try to run `"echo -e "sa\npb\nrrr\n" | ./checker 0 9 1 8 2 7 3 6 4 5"`. +``` +KO +``` +###### Does it display the right result as above? +##### Try to run `"echo -e "pb\nra\npb\nra\nsa\nra\npa\npa\n" | ./checker 0 9 1 8 2"`. +``` +OK +``` +###### Does it display the right result as above? +##### Try to run `"ARG = "4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG"`. +``` +OK +``` +###### Does it display the right result as above? + +#### General + +##### Try to run `"$ARG= "<100 random numbers>" ; ./push_swap $ARG"` with 100 random different numbers instead of the tag. +###### Does it displays less than 700 commands? +##### Try to run `"$ARG= "<100 random numbers> | ./checker $ARG" ; ./push_swap $ARG"` with the same 100 random different numbers as before instead of the tag. +###### Does it displays OK? + +#### Basic + +###### +Does the code obey the [good practices](https://github.com/01-edu/public/blob/master/subjects/good-practices.en.md)? + +###### +Is there a test file for this code? +###### +Are the tests checking each possible case? + +#### Social + +###### +Did you learn anything from this project? +###### +Would you recommend/nominate this program as an example for the rest of the school? \ No newline at end of file diff --git a/subjects/push-swap/push-swap.en.md b/subjects/push-swap/push-swap.en.md new file mode 100644 index 00000000..621ae115 --- /dev/null +++ b/subjects/push-swap/push-swap.en.md @@ -0,0 +1,167 @@ +## push-swap + +### Objectives + +Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of `int` values, two stacks (`a` and `b`) and a set of instructions. + +You will have two write 2 programs: + +- **push_swap**, which calculates and displays on the standard output the smallest program using push_swap instruction language that sorts integer arguments received. +- **checker**, which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`. + +As said before, you will have two stacks at your disposal. Your goal is to sort stack `a`, that will contain the `int` values received, in ascending order, using both stacks and a set of instructions. + +These are the instructions that you can use to sort the stack : + +- `pa` push the top first element of stack `b` to stack `a` +- `pb` push the top first element of stack `a` to stack `b` +- `sa` swap first 2 elements of stack `a` +- `sb` swap first 2 elements of stack `b` +- `ss` execute `sa` and `sb` +- `ra` rotate stack `a` (shift up all elements of stack `a` by 1, the first element becomes the last one) +- `rb` rotate stack `b` +- `rr`execute `ra` and `rb` +- `rra` reverse rotate `a` (shift down all elements of stack `a` by 1, the first element becomes the last one) +- `rrb` reverse rotate `b` +- `rrr` execute `rra` and `rrb` + +#### Example + +```console +--------------------------------------- +Init a and b : +2 +1 +3 +6 +8 +5 += = +a b +--------------------------------------- +Exec sa : +1 +2 +3 +6 +8 +5 += = +a b +--------------------------------------- +Exec pb pb pb : +6 3 +8 2 +5 1 += = +a b +--------------------------------------- +Exec ra rb (equivalent to rr): +8 2 +5 1 +6 3 += = +a b +--------------------------------------- +Exec rra and rrb (equivalent to rrr): +6 3 +8 2 +5 1 += = +a b +--------------------------------------- +Exec sa: +8 3 +6 2 +5 1 += = +a b +--------------------------------------- +Exec pa pa pa: +1 +2 +3 +5 +6 +8 += = +a b +--------------------------------------- +``` + +This project will help you learn about : + +- the use of basic algorithms +- the use of sorting algorithms +- the use of stacks + +#### The push_swap program + +- You have to write a program named push_swap, which will receive as an argument the stack a formatted as a list of integers. The first integer should be at the top of the stack. +- The program must display the smallest list of instructions possible to sort the stack `a`, with the smallest number being at the top. +- Instructions must be separated by a `\n` and nothing else. +- The goal is to sort the stack with the minimum possible number of operations. +- In case of error, you must display `Error` followed by a `\n` on the standard error. Errors are understood as: some arguments aren’t integers and/or there are duplicates. +- In case of there are no arguments the program displays nothing (0 instructions). + +```console +student$ ./push_swap 2 1 3 6 5 8 +sa +pb +pb +pb +sa +pa +pa +pa +student$ ./push_swap 0 one 2 3 +Error +student$ +``` + +#### The checker program + +- You have to write a program named checker, which will get as an argument the stack `a` formatted as a list of integers. The first argument should be at the top of the stack (be careful about the order). If no argument is given, checker stops and displays nothing. +- Checker will then read instructions on the standard input, each instruction will be followed by `\n`. Once all the instructions have been read, checker will execute them on the stack received as an argument. +- If after executing those instructions, stack `a` is actually sorted and `b` is empty, then checker must display "OK" followed by a `\n` on the standard output. In every other case, checker must display "KO" followed by a `\n` on the standard output. +- In case of error, you must display Error followed by a `\n` on the standard error. Errors include for example: some arguments are not integers, there are duplicates, an instruction don’t exist and/or is incorrectly formatted. +- In case of there are no arguments the program displays nothing. + +```console +student$ echo -e "rra\npb\nsa\nrra\npa\n" +rra +pb +sa +rra +pa +student$ echo -e "rra\npb\nsa\nrra\npa\n" | ./checker 3 2 1 0 +OK +student$ echo -e "sa\n\nrra\npb" +sa +rra +pb +student$ echo -e "sa\n\nrra\npb\n" | ./checker 3 2 1 0 +KO +student$ ./checker 3 2 one 0 +Error +student$ +``` + +### Instructions + +- Your project must be written in **Go**. +- The code must respect the [**good practices**](https://github.com/01-edu/public/good-practices.en.md). +- It is recommended that the code should present a **test file**. +- The first executable file must be named **checker** and the second **push_swap**. +- You have to be able to handle the errors. + +### Usage + +```console +student$ ARG="4 67 3 87 23"; ./push_swap $ARG | wc -l + 6 +student$ ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG +OK +``` + +If the program checker displays KO, it means that your **push_swap** came up with a list of instructions that doesn't sort the list. From b0a8ad76da5b1b900f912674b88fb111b6910d13 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Fri, 3 Jan 2020 18:10:59 +0000 Subject: [PATCH 5/8] removing out of folder push_swap --- subjects/push-swap.en.md | 152 --------------------------------------- 1 file changed, 152 deletions(-) delete mode 100644 subjects/push-swap.en.md diff --git a/subjects/push-swap.en.md b/subjects/push-swap.en.md deleted file mode 100644 index d57337a3..00000000 --- a/subjects/push-swap.en.md +++ /dev/null @@ -1,152 +0,0 @@ -## push-swap - -### Objectives - -Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of `int` values, two stacks (`a` and `b`) and a set of instructions. - -You will have two write 2 programs: - -- **push_swap**, which calculates and displays on the standard output the smallest program using push_swap instruction language that sorts integer arguments received. -- **checker**, which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`. - -As said before, you will have two stacks at your disposal. Your goal is to sort stack `a`, that will contain the `int` values received, in ascending order, using both stacks and a set of instructions. - -These are the instructions that you can use to sort the stack : - -- `pa` push the top first element of stack `b` to stack `a` -- `pb` push the top first element of stack `a` to stack `b` -- `sa` swap first 2 elements of stack `a` -- `sb` swap first 2 elements of stack `b` -- `ss` execute `sa` and `sb` -- `ra` rotate stack `a` (shift up all elements of stack `a` by 1, the first element becomes the last one) -- `rb` rotate stack `b` -- `rr`execute `ra` and `rb` -- `rra` reverse rotate `a` (shift down all elements of stack `a` by 1, the first element becomes the last one) -- `rrb` reverse rotate `b` -- `rrr` execute `rra` and `rrb` - -#### Example - -```console ---------------------------------------- -Init a and b : -2 -1 -3 -6 -8 -5 -= = -a b ---------------------------------------- -Exec sa : -1 -2 -3 -6 -8 -5 -= = -a b ---------------------------------------- -Exec pb pb pb : -6 3 -8 2 -5 1 -= = -a b ---------------------------------------- -Exec ra rb (equivalent to rr): -8 2 -5 1 -6 3 -= = -a b ---------------------------------------- -Exec rra and rrb (equivalent to rrr): -6 3 -8 2 -5 1 -= = -a b ---------------------------------------- -Exec sa: -8 3 -6 2 -5 1 -= = -a b ---------------------------------------- -Exec pa pa pa: -1 -2 -3 -5 -6 -8 -= = -a b ---------------------------------------- -``` - -This project will help you learn about : - -- the use of basic algorithms -- the use of sorting algorithms -- the use of stacks - -#### The push_swap program - -- You have to write a program named push_swap, which will receive as an argument the stack a formatted as a list of integers. The first integer should be at the top of the stack. -- The program must display the smallest list of instructions possible to sort the stack `a`, with the smallest number being at the top. -- Instructions must be separated by a `\n` and nothing else. -- The goal is to sort the stack with the minimum possible number of operations. -- In case of error, you must display `Error` followed by a `\n` on the standard error. Errors include for example: some arguments aren’t integers and/or there are duplicates. - -```console -$>./push_swap 2 1 3 6 5 8 -sa -pb -pb -pb -sa -pa -pa -pa -$>./push_swap 0 one 2 3 -Error -$> -``` - -#### The checker program - -- You have to write a program named checker, which will get as an argument the stack a formatted as a list of integers. The first argument should be at the top of the stack (be careful about the order). If no argument is given checker stops and displays nothing. -- Checker will then read instructions on the standard input, each instruction will be followed by `\n`. Once all the instructions have been read, checker will execute them on the stack received as an argument. -- If after executing those instructions, stack `a` is actually sorted and `b` is empty, then checker must display "OK" followed by a `\n` on the standard output. In every other case, checker must display "KO" followed by a `\n` on the standard output. -- In case of error, you must display Error followed by a `\n` on the standard error. Errors include for example: some arguments are not integers, there are duplicates, an instruction don’t exist and/or is incorrectly formatted. - -```console -$>./checker 3 2 1 0 -rra -pb -sa -rra -pa -OK -$>./checker 3 2 1 0 -sa -rra -pb -KO -$>./checker 3 2 one 0 -Error -$> -``` - -### Instructions - -- Your project must be written in **Go**. -- The code must respect the [**good practices**](https://github.com/01-edu/public/good-practices.en.md). -- It is recommended that the code should present a **test file**. -- The first executable file must be named **checker** and the second **push_swap**. -- You have to be able to handle the errors. From 7ea60e86bbe70b7ce3a9dbb4208095211d9aa442 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Mon, 6 Jan 2020 10:42:59 +0000 Subject: [PATCH 6/8] examples correction --- subjects/push-swap/push-swap.en.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/subjects/push-swap/push-swap.en.md b/subjects/push-swap/push-swap.en.md index 621ae115..0d92853a 100644 --- a/subjects/push-swap/push-swap.en.md +++ b/subjects/push-swap/push-swap.en.md @@ -105,7 +105,7 @@ This project will help you learn about : - In case of there are no arguments the program displays nothing (0 instructions). ```console -student$ ./push_swap 2 1 3 6 5 8 +student$ ./push_swap "2 1 3 6 5 8" sa pb pb @@ -114,7 +114,7 @@ sa pa pa pa -student$ ./push_swap 0 one 2 3 +student$ ./push_swap "0 one 2 3" Error student$ ``` @@ -134,15 +134,15 @@ pb sa rra pa -student$ echo -e "rra\npb\nsa\nrra\npa\n" | ./checker 3 2 1 0 +student$ echo -e "rra\npb\nsa\nrra\npa\n" | ./checker "3 2 1 0" OK student$ echo -e "sa\n\nrra\npb" sa rra pb -student$ echo -e "sa\n\nrra\npb\n" | ./checker 3 2 1 0 +student$ echo -e "sa\n\nrra\npb\n" | ./checker "3 2 1 0" KO -student$ ./checker 3 2 one 0 +student$ echo -e "sa\n\nrra\npb\n" | ./checker "3 2 one 0" Error student$ ``` @@ -158,9 +158,9 @@ student$ ### Usage ```console -student$ ARG="4 67 3 87 23"; ./push_swap $ARG | wc -l +student$ ARG="4 67 3 87 23"; ./push_swap "$ARG" | wc -l 6 -student$ ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG +student$ ARG="4 67 3 87 23"; ./push_swap "$ARG" | ./checker "$ARG" OK ``` From 3ccc46e05e6b02f91a7d50c10986b4481b633174 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Tue, 7 Jan 2020 09:24:26 +0000 Subject: [PATCH 7/8] Fix Questions Answers --- subjects/push-swap/push-swap.audit.en.md | 26 ++---------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/subjects/push-swap/push-swap.audit.en.md b/subjects/push-swap/push-swap.audit.en.md index dfb3efcf..2de3a211 100644 --- a/subjects/push-swap/push-swap.audit.en.md +++ b/subjects/push-swap/push-swap.audit.en.md @@ -1,29 +1,10 @@ #### Functional -###### Is the solution of the push_swap the simplest possible? (with the fewer instructions) -###### Is the program sorting the stack correctly? - ##### Try to run `"./push_swap"`. -``` - -``` ###### Does it display nothing? ##### Try to run `"./push_swap 2 1 3 6 5 8"`. -``` -sa -pb -pb -pb -sa -pa -pa -pa -``` -###### Does it display the right result as above? +###### Does it display a valid solution and less than 9 instructions? ##### Try to run `"./push_swap 0 1 2 3 4 5"`. -``` - -``` ###### Does it display nothing? ##### Try to run `"./push_swap 0 one 2 3"`. ``` @@ -36,11 +17,8 @@ Error ``` ###### Does it display the right result as above? ##### Try to run `"./push_swap <5 random numbers>"` with 5 random numbers instead of the tag. -###### Does it displays less than 12 commands? +###### Does it displays a valid solution and less than 12 instructions? ##### Try to run `"echo -e " " | ./checker "`. -``` - -``` ###### Does it display the right result as above? ##### Try to run `"./checker 0 one 2 3"`. ``` From dbd56f01bed67099ee2696e9e13c7d01d420dbe0 Mon Sep 17 00:00:00 2001 From: lee Date: Fri, 10 Jan 2020 11:22:07 +0000 Subject: [PATCH 8/8] some corrections --- subjects/push-swap/push-swap.audit.en.md | 29 +++++++++++++----------- subjects/push-swap/push-swap.en.md | 21 ++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/subjects/push-swap/push-swap.audit.en.md b/subjects/push-swap/push-swap.audit.en.md index 2de3a211..c43a5177 100644 --- a/subjects/push-swap/push-swap.audit.en.md +++ b/subjects/push-swap/push-swap.audit.en.md @@ -16,30 +16,31 @@ Error Error ``` ###### Does it display the right result as above? + ##### Try to run `"./push_swap <5 random numbers>"` with 5 random numbers instead of the tag. ###### Does it displays a valid solution and less than 12 instructions? -##### Try to run `"echo -e " " | ./checker "`. -###### Does it display the right result as above? + +##### Try to run `"./checker "` and input nothing. +###### Does it display nothing? + ##### Try to run `"./checker 0 one 2 3"`. ``` Error ``` ###### Does it display the right result as above? -##### Try to run `"./checker 1 2 2 3"`. -``` -Error -``` -###### Does it display the right result as above? + ##### Try to run `"echo -e "sa\npb\nrrr\n" | ./checker 0 9 1 8 2 7 3 6 4 5"`. ``` KO ``` ###### Does it display the right result as above? + ##### Try to run `"echo -e "pb\nra\npb\nra\nsa\nra\npa\npa\n" | ./checker 0 9 1 8 2"`. ``` OK ``` ###### Does it display the right result as above? + ##### Try to run `"ARG = "4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG"`. ``` OK @@ -48,19 +49,21 @@ OK #### General -##### Try to run `"$ARG= "<100 random numbers>" ; ./push_swap $ARG"` with 100 random different numbers instead of the tag. -###### Does it displays less than 700 commands? -##### Try to run `"$ARG= "<100 random numbers> | ./checker $ARG" ; ./push_swap $ARG"` with the same 100 random different numbers as before instead of the tag. -###### Does it displays OK? +##### Try to run `"$ARG= "<100 random numbers>"; ./push_swap $ARG"` with 100 random different numbers instead of the tag. +###### +Does it displays less than 700 commands? +##### Try to run `"$ARG= "<100 random numbers>; ./push_swap $ARG | ./checker $ARG"` with the same 100 random different numbers as before instead of the tag. +``` +OK +``` +###### +Does it displays the right result as above? #### Basic ###### +Does the code obey the [good practices](https://github.com/01-edu/public/blob/master/subjects/good-practices.en.md)? - ###### +Is there a test file for this code? ###### +Are the tests checking each possible case? #### Social ###### +Did you learn anything from this project? -###### +Would you recommend/nominate this program as an example for the rest of the school? \ No newline at end of file +###### +Would you recommend/nominate this program as an example for the rest of the school? diff --git a/subjects/push-swap/push-swap.en.md b/subjects/push-swap/push-swap.en.md index 0d92853a..0808c61a 100644 --- a/subjects/push-swap/push-swap.en.md +++ b/subjects/push-swap/push-swap.en.md @@ -4,7 +4,7 @@ Push_swap is a very simple and highly effective algorithm.You have at your disposal a list of `int` values, two stacks (`a` and `b`) and a set of instructions. -You will have two write 2 programs: +You will have to write 2 programs: - **push_swap**, which calculates and displays on the standard output the smallest program using push_swap instruction language that sorts integer arguments received. - **checker**, which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays `OK` if integers are sorted. Otherwise, it will display `KO`. @@ -28,7 +28,6 @@ These are the instructions that you can use to sort the stack : #### Example ```console ---------------------------------------- Init a and b : 2 1 @@ -86,7 +85,6 @@ Exec pa pa pa: 8 = = a b ---------------------------------------- ``` This project will help you learn about : @@ -116,6 +114,7 @@ pa pa student$ ./push_swap "0 one 2 3" Error +student$ ./push_swap student$ ``` @@ -128,6 +127,13 @@ student$ - In case of there are no arguments the program displays nothing. ```console +student$ ./checker "3 2 1 0" +sa +rra +pb +KO +student$ echo -e "rra\npb\nsa\n" | ./checker "3 2 one 0" +Error student$ echo -e "rra\npb\nsa\nrra\npa\n" rra pb @@ -136,14 +142,7 @@ rra pa student$ echo -e "rra\npb\nsa\nrra\npa\n" | ./checker "3 2 1 0" OK -student$ echo -e "sa\n\nrra\npb" -sa -rra -pb -student$ echo -e "sa\n\nrra\npb\n" | ./checker "3 2 1 0" -KO -student$ echo -e "sa\n\nrra\npb\n" | ./checker "3 2 one 0" -Error +student$ ./checker student$ ```