diff --git a/builds/print.o b/builds/print.o index 4d75650..7ce61fc 100644 Binary files a/builds/print.o and b/builds/print.o differ diff --git a/builds/pushswap.o b/builds/pushswap.o index f394b4e..b3c2860 100644 Binary files a/builds/pushswap.o and b/builds/pushswap.o differ diff --git a/builds/swap.o b/builds/swap.o index 13f234d..970d524 100644 Binary files a/builds/swap.o and b/builds/swap.o differ diff --git a/includes/pushswap.h b/includes/pushswap.h index 441bdec..8f25f1b 100644 --- a/includes/pushswap.h +++ b/includes/pushswap.h @@ -33,7 +33,7 @@ t_list *sort_algo(t_stack *stack); /* ** print.c */ -void fill_solution(t_stack **a, t_stack **b, t_list **lst, char *c); +void fill_solution(t_stack *a, t_stack *b, t_list **lst, char *c); void print_stack(t_stack *stack, char c); void print_result(t_list *lst); diff --git a/pushswap b/pushswap index ae511b4..055eb92 100755 Binary files a/pushswap and b/pushswap differ diff --git a/srcs/print.c b/srcs/print.c index 1965d9c..ea3f92a 100644 --- a/srcs/print.c +++ b/srcs/print.c @@ -1,11 +1,26 @@ #include "pushswap.h" -void fill_solution(t_stack **a, t_stack **b, t_list **solution, char *sp) +void fill_solution(t_stack *a, t_stack *b, t_list **solution, char *sp) { - (void)a; + char *stack; + (void)b; - ft_lstadd_back(solution, ft_lstnew(sp)); + stack = ft_strdup(sp); + stack = ft_strjoinfree(stack, ft_strdup(" a")); + while(a) + { + stack = ft_strjoinfree(stack, ft_strdup(" ")); + stack = ft_strjoinfree(stack, ft_itoa(a->n)); + a = a->next; + } + while(b) + { + stack = ft_strjoinfree(stack, ft_strdup(" ")); + stack = ft_strjoinfree(stack, ft_itoa(a->n)); + b = b->next; + } + ft_lstadd_back(solution, ft_lstnew(stack)); } void print_stack(t_stack *stack, char c) diff --git a/srcs/pushswap.c b/srcs/pushswap.c index 96a371b..67d95fd 100644 --- a/srcs/pushswap.c +++ b/srcs/pushswap.c @@ -1,5 +1,6 @@ #include "pushswap.h" +#include void is_valid(int ac, char **av) { diff --git a/srcs/swap.c b/srcs/swap.c index 838efc1..0f88029 100644 --- a/srcs/swap.c +++ b/srcs/swap.c @@ -12,7 +12,7 @@ t_list *sa(t_stack **stack, t_list **solution) tmp = a->n; a->n = a->next->n; a->next->n = tmp; - fill_solution(stack, NULL, solution, ft_strdup("sa")); + fill_solution(*stack, NULL, solution, ft_strdup("sa")); return (NULL); }