special sort for 3 ok

This commit is contained in:
hugogogo
2021-09-27 00:48:40 +02:00
parent 7d563f3362
commit bb2a08833a
13 changed files with 32 additions and 4 deletions
+2 -1
View File
@@ -30,7 +30,8 @@ SRCS = push_swap.c \
algo_bubble_sort.c \ algo_bubble_sort.c \
minisort.c \ minisort.c \
minisort_by_rank.c \ minisort_by_rank.c \
minisort_2ways_bubble_sort.c minisort_2ways_bubble_sort.c \
special_sorts_3_5.c
ODIR = ./builds ODIR = ./builds
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -48,7 +48,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *lst);
/* /*
** spcecial_sorts_3_5.c ** spcecial_sorts_3_5.c
*/ */
void special_sort_3(t_stack **a, t_stack **b, t_list *solution); void special_sort_3(t_stack **a, t_list *solution);
void special_sort_5(t_stack **a, t_stack **b, t_list *solution); void special_sort_5(t_stack **a, t_stack **b, t_list *solution);
/* /*
BIN
View File
Binary file not shown.
+3 -1
View File
@@ -142,9 +142,11 @@ void recursif_sort(t_stack **a, t_stack **b, t_list *solution)
void hugo_sort(t_stack **a, t_stack **b, t_list *solution) void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
{ {
if (sublist_size(*a) <= 3) if (sublist_size(*a) <= 3)
special_sort_3(a, b, solution); special_sort_3(a, solution);
/*
else if (sublist_size(*a) <= 5) else if (sublist_size(*a) <= 5)
special_sort_5(a, b, solution); special_sort_5(a, b, solution);
*/
else else
recursif_sort(a, b, solution); recursif_sort(a, b, solution);
} }
+26 -1
View File
@@ -1,10 +1,35 @@
#include "push_swap.h" #include "push_swap.h"
void special_sort_3(t_stack **a, t_stack **b, t_list *solution) void special_sort_3(t_stack **a, t_list *solution)
{ {
int order;
int size;
size = sublist_size(*a);
order = order_is(*a, size);
if (order == 12)
sa(a, &solution);
if (order == 123)
{
ra(a, &solution);
sa(a, &solution);
}
if (order == 132)
rra(a, &solution);
if (order == 213)
ra(a, &solution);
if (order == 231)
{
rra(a, &solution);
sa(a, &solution);
}
if (order == 312)
sa(a, &solution);
} }
/*
void special_sort_5(t_stack **a, t_stack **b, t_list *solution) void special_sort_5(t_stack **a, t_stack **b, t_list *solution)
{ {
} }
*/