blob: 91259c32f6563d5e7924d887e5864485f06af874 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# push_swap [](https://travis-ci.com/HappyTramp/push_swap)
push_swap project of school 42
# Goal
We have 2 stack at our disposal A and B.
Stack A is given has an argument to our program,
we have to sort it using only a limited set of operand.
* `sa` swap the 2 topmost element of A
* `sb` swap the 2 topmost element of B
* `ss` swap the 2 topmost element of A & B
* `pa` pop top of B and push it to A
* `pb` pop top of A and push it to B
* `ra` rotate A, everything is shifted up (top becomes bottom)
* `rb` rotate B
* `rr` rotate A & B
* `rra` reverse rotate A,
everything is shifted down (bottom becomes top)
* `rrb` reverse rotate B
* `rrr` reverse rotate A & B
# Usage
```
make all
export ARG=$(echo ./random_stack.rb 1 20)
./push_swap $(echo $ARG) | ./checker $(echo $ARG)
```
# Visualizer
```
export ARG=$(echo ./random_stack.rb 1 20)
./push_swap $(echo $ARG) | ./visualizer.rb $(echo $ARG)
```
# Test
```
./test.sh 20 1 100
```
Test argument stack parsing
```
./test.sh --error
```
# Benchmark
Make sure to have Python3.6 >=
```
python benchmark.py 10 100 5 10
python benchmark_plot.py
```
Plot operation distribution
```
python benchmark_plot.py --dist
```
|