toutes les actions implementees

This commit is contained in:
hugogogo
2021-06-15 17:15:21 +02:00
parent 9842a20f6e
commit 8121128ad5
13 changed files with 62 additions and 10 deletions

View File

@@ -1,7 +1,41 @@
#include "push_swap.h"
t_list *ra(t_stack **stack, t_list **lst);
t_list *rb(t_stack **stack, t_list **lst);
t_list *rr(t_stack **a, t_stack **b, t_list **lst);
void rotate(t_stack **stack)
{
t_stack *tmp;
t_stack *first;
first = *stack;
tmp = *stack;
if (!tmp || !(tmp->next))
return ;
*stack = (*stack)->next;
while (tmp->next)
tmp = tmp->next;
tmp->next = first;
first->next = NULL;
}
t_list *ra(t_stack **a, t_list **lst)
{
rotate(a);
fill_solution(*lst, ft_strdup("ra"));
return (NULL);
}
t_list *rb(t_stack **b, t_list **lst)
{
rotate(b);
fill_solution(*lst, ft_strdup("rb"));
return (NULL);
}
t_list *rr(t_stack **a, t_stack **b, t_list **lst)
{
rotate(a);
rotate(b);
fill_solution(*lst, ft_strdup("rr"));
return (NULL);
}