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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
push_swap

Binary file not shown.

View File

@@ -9,10 +9,17 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
pb(b, a, &solution);
pb(b, a, &solution);
pb(b, a, &solution);
pb(b, a, &solution);
pb(b, a, &solution);
pa(a, b, &solution);
sa(a, &solution);
sb(b, &solution);
sa(a, &solution);
rra(a, &solution);
rrb(b, &solution);
rrr(a, b, &solution);
ra(a, &solution);
rb(b, &solution);
rr(a, b, &solution);
}

View File

@@ -1,14 +1,14 @@
#include "push_swap.h"
t_list *rra(t_stack **stack, t_list **lst)
void reverse_rotate(t_stack **stack)
{
t_stack *tmp;
t_stack *before;
tmp = *stack;
if (!tmp || !(tmp->next))
return (NULL);
return ;
while (tmp->next)
{
before = tmp;
@@ -17,15 +17,26 @@ t_list *rra(t_stack **stack, t_list **lst)
tmp->next = *stack;
*stack = tmp;
before->next = NULL;
}
t_list *rra(t_stack **a, t_list **lst)
{
reverse_rotate(a);
fill_solution(*lst, ft_strdup("rra"));
return (NULL);
}
t_list *rrb(t_stack **stack, t_list **lst)
t_list *rrb(t_stack **b, t_list **lst)
{
t_stack *tmp;
tmp = *stack;
reverse_rotate(b);
fill_solution(*lst, ft_strdup("rrb"));
return (NULL);
}
t_list *rrr(t_stack **a, t_stack **b, t_list **lst)
{
reverse_rotate(a);
reverse_rotate(b);
fill_solution(*lst, ft_strdup("rrr"));
return (NULL);
}
t_list *rrr(t_stack **a, t_stack **b, t_list **lst);

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);
}