diff --git a/builds/algo.o b/builds/algo.o index 7fdc3e4..d47273b 100644 Binary files a/builds/algo.o and b/builds/algo.o differ diff --git a/builds/algo_bubble_sort.o b/builds/algo_bubble_sort.o index 2a7786b..0c034c7 100644 Binary files a/builds/algo_bubble_sort.o and b/builds/algo_bubble_sort.o differ diff --git a/builds/print.o b/builds/print.o index f674759..48acbb9 100644 Binary files a/builds/print.o and b/builds/print.o differ diff --git a/builds/push.o b/builds/push.o index f3d6f90..e1eb539 100644 Binary files a/builds/push.o and b/builds/push.o differ diff --git a/builds/push_swap.o b/builds/push_swap.o index b3e78bc..f3adcdd 100644 Binary files a/builds/push_swap.o and b/builds/push_swap.o differ diff --git a/builds/reverse_rotate.o b/builds/reverse_rotate.o index 98ca444..3022223 100644 Binary files a/builds/reverse_rotate.o and b/builds/reverse_rotate.o differ diff --git a/builds/rotate.o b/builds/rotate.o index 099a619..0105699 100644 Binary files a/builds/rotate.o and b/builds/rotate.o differ diff --git a/builds/stop.o b/builds/stop.o index 53d51e1..5f981e3 100644 Binary files a/builds/stop.o and b/builds/stop.o differ diff --git a/builds/swap.o b/builds/swap.o index 7673fb8..8df6c67 100644 Binary files a/builds/swap.o and b/builds/swap.o differ diff --git a/push_swap b/push_swap index acb6c8d..a23af83 100755 Binary files a/push_swap and b/push_swap differ diff --git a/srcs/algo.c b/srcs/algo.c index 0c25839..8d251f9 100644 --- a/srcs/algo.c +++ b/srcs/algo.c @@ -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); } diff --git a/srcs/reverse_rotate.c b/srcs/reverse_rotate.c index bfe8b7c..60d4fcd 100644 --- a/srcs/reverse_rotate.c +++ b/srcs/reverse_rotate.c @@ -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); diff --git a/srcs/rotate.c b/srcs/rotate.c index a6212b5..68b9c32 100644 --- a/srcs/rotate.c +++ b/srcs/rotate.c @@ -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); +}