diff --git a/.vscode/launch.json b/.vscode/launch.json index 50e7029..e7f190e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/push_swap", - "args": ["2", "5", "4", "1"], + "args": ["20", "86", "63", "13", "84"], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], diff --git a/inc/push_swap.h b/inc/push_swap.h index 777e6ef..aeb7d56 100644 --- a/inc/push_swap.h +++ b/inc/push_swap.h @@ -21,6 +21,7 @@ typedef struct s_state t_list *b; } t_state; +int rotate_a_to_top(t_state *state); int new_element(t_list **stack, const char *str); t_list *ft_lstat(t_list *list, int n); void print_stack(const char *name, t_list *stack); diff --git a/src/moves/push.c b/src/moves/push.c index 696fe47..54f40eb 100644 --- a/src/moves/push.c +++ b/src/moves/push.c @@ -16,13 +16,13 @@ void pb(t_state *state) { push(&(state->a), &(state->b)); - ft_printf("pa\n"); + ft_printf("pb\n"); } void pa(t_state *state) { push(&(state->b), &(state->a)); - ft_printf("pb\n"); + ft_printf("pa\n"); } void push(t_list **stack_1, t_list **stack_2) diff --git a/src/moves/swap.c b/src/moves/swap.c index 1f62150..b48cdc9 100644 --- a/src/moves/swap.c +++ b/src/moves/swap.c @@ -22,7 +22,7 @@ void sa(t_state *state) void sb(t_state *state) { swap(&(state->b)); - ft_printf("rb\n"); + ft_printf("sb\n"); } void ss(t_state *state) diff --git a/src/sort/sort5.c b/src/sort/sort5.c index 5098451..5e30124 100644 --- a/src/sort/sort5.c +++ b/src/sort/sort5.c @@ -23,20 +23,24 @@ int rotate_a_to_top(t_state *state) int merge_to_a(t_state *state) { - int n; + int n; n = ft_lstsize(state->a); if (*(int *) state->b->content < stack_min(state->a)) + { pa(state); + return (0); + } else if (*(int *) state->b->content > stack_max(state->a)) { rotate_a_to_top(state); pa(state); - rra(state); + ra(state); + return (0); } while (*((int *) state->b->content) > *((int *) state->a->content) && n > 0) { - rra(state); + ra(state); n--; } pa(state);