-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmart_sort.c
More file actions
52 lines (48 loc) · 1.48 KB
/
smart_sort.c
File metadata and controls
52 lines (48 loc) · 1.48 KB
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
/* ************************************************************************** */
/* */
/* :::::::: */
/* smart_sort.c :+: :+: */
/* +:+ */
/* By: rcorke <rcorke@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2019/08/16 15:35:59 by rcorke #+# #+# */
/* Updated: 2019/08/19 12:42:07 by rcorke ######## odam.nl */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void smart_sort_finish_b(t_ps *ps, int len, int rotated, int pushed)
{
ps->a_value = pushed;
ps->a_done = 0;
while (rotated > 0)
{
reverse_b(ps);
rotated--;
}
if (pushed < 4)
sort_3_a(ps);
if (len < 7)
sort_3_b(ps);
}
void smart_sort_finish_a_inoff(t_ps *ps, int len, int rotated, \
int pushed)
{
while (rotated > 0)
{
reverse_a(ps);
rotated--;
}
ps->a_done = 0;
if (pushed < 4)
sort_3_b(ps);
if (len <= 7)
sort_3_a(ps);
}
void smart_sort_finish_a_off(t_ps *ps, int len, int pushed)
{
ps->a_done = 0;
if (pushed < 4)
sort_3_b(ps);
if (len <= 7)
sort_3_a(ps);
}