Files
42_INT_06_pushwap/srcs/swap.c
2021-06-26 23:36:24 +02:00

37 lines
543 B
C

#include "push_swap.h"
void swap(t_stack **stack)
{
t_stack *tmp;
tmp = *stack;
if (!(tmp->next))
return ;
*stack = (*stack)->next;
tmp->next = (*stack)->next;
(*stack)->next = tmp;
}
t_list *sa(t_stack **a, t_list **solution)
{
swap(a);
fill_solution(*solution, "sa");
return (NULL);
}
t_list *sb(t_stack **b, t_list **solution)
{
swap(b);
fill_solution(*solution, "sb");
return (NULL);
}
t_list *ss(t_stack **a, t_stack **b, t_list **solution)
{
swap(a);
swap(b);
fill_solution(*solution, "sb");
return (NULL);
}