#include "push_swap.h" void fill_solution(t_stack *a, t_stack *b, t_list **solution, char *sp) { char *stack; 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; } stack = ft_strjoinfree(stack, ft_strdup("!b:")); 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_result(t_list *result, int flag) { char **part; if (!flag) result = result->next; while (result) { part = ft_split(result->content, '!'); ft_printf("%s\n", part[0]); if (flag) { ft_printf(" %s\n", part[1]); ft_printf(" %s\n", part[2]); } result = result->next; } }