-
Notifications
You must be signed in to change notification settings - Fork 0
/
moves_rot.c
52 lines (45 loc) · 1.36 KB
/
moves_rot.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
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* moves_rot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: issierra <issierra@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 08:39:44 by issierra #+# #+# */
/* Updated: 2023/12/24 08:51:03 by issierra ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
t_stack *ft_lst_last(t_stack *lst)
{
while (lst && lst->next)
lst = lst->next;
return (lst);
}
void rot(t_stack **ptr)
{
t_stack *tmp;
t_stack *last;
last = *ptr;
last = ft_lst_last(last);
tmp = *ptr;
*ptr = (*ptr)->next;
last->next = tmp;
last->next->next = NULL;
}
void rr(t_stack **a, t_stack**b)
{
rot(a);
rot(b);
ft_printf("rr\n");
}
void ra(t_stack **ptr)
{
rot(ptr);
ft_printf("ra\n");
}
void rb(t_stack **ptr)
{
rot(ptr);
ft_printf("rb\n");
}