-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_swap_rra.c
51 lines (45 loc) · 1.58 KB
/
push_swap_rra.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap_rra.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: coskelet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/08 15:47:32 by coskelet #+# #+# */
/* Updated: 2022/03/08 15:47:34 by coskelet ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static short l_need_to_rra(t_stacks *st)
{
long tmp_al;
if (st->shrt)
return (0);
tmp_al = (long)ft_lstlast(st->a)->content;
if (tmp_al <= st->sigma2[0] || (r_side(st) && tmp_al <= st->sigma[0]))
return (1);
else
return (0);
}
static short sh_need_to_rra(t_stacks *st)
{
long tmp_al;
if (!st->shrt && st->a_size >= SH_STACK)
return (0);
find_short_boundaries(st);
tmp_al = (long)ft_lstlast(st->a)->content;
if ((sh_sigma2(st) && tmp_al <= st->sh_sigma2[0])
|| (r_side(st) && tmp_al <= st->sh_sigma[0]))
return (1);
else
return (0);
}
void need_to_rra(short *a, t_stacks *st)
{
if (NULL != st->a)
{
if (sh_need_to_rra(st) || l_need_to_rra(st))
*a = 1;
}
return ;
}