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

View File

@@ -30,7 +30,8 @@ SRCS = push_swap.c \
algo_bubble_sort.c \
minisort.c \
minisort_by_rank.c \
minisort_2ways_bubble_sort.c
minisort_2ways_bubble_sort.c \
special_sorts_3_5.c
ODIR = ./builds

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
builds/special_sorts_3_5.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -48,7 +48,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *lst);
/*
** 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);
/*

BIN
push_swap

Binary file not shown.

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)
{
if (sublist_size(*a) <= 3)
special_sort_3(a, b, solution);
special_sort_3(a, solution);
/*
else if (sublist_size(*a) <= 5)
special_sort_5(a, b, solution);
*/
else
recursif_sort(a, b, solution);
}

View File

@@ -1,10 +1,35 @@
#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)
{
}
*/