-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules1.c
48 lines (42 loc) · 1.39 KB
/
rules1.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rules1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: macos <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/11 23:10:40 by macos #+# #+# */
/* Updated: 2023/02/11 23:11:49 by macos ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void rotate(t_data **rot)
{
t_data *end;
t_data *start;
if (ft_lstsize(*rot) < 2)
return ;
start = *rot;
end = ft_lstlast(*rot);
*rot = (*rot)->next;
end->next = start;
start->next = NULL;
}
void ra(t_data **a_rot)
{
rotate(a_rot);
write(1, "ra\n", 3);
}
void rb(t_data **b_rot)
{
rotate(b_rot);
write(1, "rb\n", 3);
}
void rr(t_data **a_rot, t_data **b_rot)
{
if ((ft_lstsize(*a_rot) < 2) || (ft_lstsize(*b_rot) < 2))
return ;
rotate(a_rot);
rotate(b_rot);
write(1, "rr\n", 3);
}