38 lines
666 B
C
38 lines
666 B
C
|
|
#include "push_swap.h"
|
|
|
|
t_list *pa(t_stack **a, t_stack **b, t_list **solution)
|
|
{
|
|
t_stack *tmp;
|
|
|
|
if (!(tmp = ft_calloc(1, sizeof(t_stack))))
|
|
ps_stop(*a, *b, *solution, 2);
|
|
tmp->n = (*b)->n;
|
|
tmp->next = NULL;
|
|
(*a)->next = tmp;
|
|
fill_solution(solution, ft_strdup("pa"));
|
|
return (NULL);
|
|
}
|
|
|
|
t_list *pb(t_stack **dst, t_stack **src, t_list **solution)
|
|
{
|
|
t_stack *a;
|
|
t_stack *b;
|
|
t_stack *tmp;
|
|
|
|
a = *src;
|
|
b = *dst;
|
|
|
|
if (!(b = ft_calloc(1, sizeof(t_stack))))
|
|
ps_stop(a, b, *solution, 2);
|
|
b->n = a->n;
|
|
b->next = NULL;
|
|
|
|
tmp = a->next;
|
|
a->n = a->next->n;
|
|
a->next = a->next->next;
|
|
free(tmp);
|
|
fill_solution(solution, ft_strdup("pa"));
|
|
return (NULL);
|
|
}
|