diff --git a/builds/algo.o b/builds/algo.o index 00f5526..6f077cf 100644 Binary files a/builds/algo.o and b/builds/algo.o differ diff --git a/builds/print.o b/builds/print.o index 9e08696..ab8e164 100644 Binary files a/builds/print.o and b/builds/print.o differ diff --git a/builds/push_swap.o b/builds/push_swap.o index 6855ce1..75073ba 100644 Binary files a/builds/push_swap.o and b/builds/push_swap.o differ diff --git a/push_swap b/push_swap index c2ae788..14c4c8c 100755 Binary files a/push_swap and b/push_swap differ diff --git a/srcs/algo.c b/srcs/algo.c index f64d96d..b25f482 100644 --- a/srcs/algo.c +++ b/srcs/algo.c @@ -6,25 +6,16 @@ t_list *dup_n_fill(t_stack *a) t_list *sort; int *i; int j; - int *x; j = 0; - i = (int *)ft_calloc(3, sizeof(int)); sort = NULL; while(a) { - if(sort){x = sort->content; ft_printf("[%i / ", x[0]);} - + i = (int *)ft_calloc(3, sizeof(int)); i[0] = a->n; i[1] = j; i[2] = 0; - - if(sort){x = sort->content; ft_printf("%i] ", x[0]);} - ft_lstadd_back(&sort, ft_lstnew(i)); - - x = sort->content; ft_printf("[%i]\n", x[0]); - a = a->next; j++; } @@ -36,17 +27,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution) (void)b; (void)a; (void)solution; - t_list *sort; - sort = dup_n_fill(*a); - int *i; - while(sort) - { - i = sort->content; - ft_printf("%i - %i - %i\n", i[0], i[1], i[2]); - sort = sort->next; - } - /* sa(a, &solution); pb(b, a, &solution); pb(b, a, &solution); @@ -59,6 +40,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution) sa(a, &solution); rra(a, &solution); rrb(b, &solution); + /* rrr(a, b, &solution); ra(a, &solution); rb(b, &solution); diff --git a/srcs/print.c b/srcs/print.c index 5eb0f67..4f30948 100644 --- a/srcs/print.c +++ b/srcs/print.c @@ -17,18 +17,13 @@ */ void fill_solution(t_list *solution, char *sp) { - t_stack **tmp1; - t_stack **tmp2; t_stack *a; t_stack *b; char *stack; - tmp1 = solution->content; - tmp2 = solution->next->content; - a = *tmp1; - b = *tmp2; - stack = ft_strdup(sp); - stack = ft_strjoinfree(stack, ft_strdup("!a:")); + a = *(t_stack **)(solution->content); + b = *(t_stack **)(solution->next->content); + stack = ft_strjoinfree(ft_strdup(sp), ft_strdup("!a:")); while(a != NULL) { stack = ft_strjoinfree(stack, ft_strdup(" ")); @@ -36,7 +31,7 @@ void fill_solution(t_list *solution, char *sp) a = a->next; } stack = ft_strjoinfree(stack, ft_strdup("!b:")); - while(b) + while(b != NULL) { stack = ft_strjoinfree(stack, ft_strdup(" ")); stack = ft_strjoinfree(stack, ft_itoa(b->n)); diff --git a/srcs/push_swap.c b/srcs/push_swap.c index 18a20ce..bed0926 100644 --- a/srcs/push_swap.c +++ b/srcs/push_swap.c @@ -53,7 +53,7 @@ t_list *launch_algo(t_stack *a, int flag) solution = ft_lstnew(&a); ft_lstadd_back(&solution, ft_lstnew(&b)); if (flag) - fill_solution(solution, ft_strdup("start")); + fill_solution(solution, "start"); hugo_sort(&a, &b, solution); //bubble_sort(&a, &b, solution); return (solution);