special sort for 3 ok
This commit is contained in:
3
Makefile
3
Makefile
@@ -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
builds/algo.o
BIN
builds/algo.o
Binary file not shown.
Binary file not shown.
BIN
builds/push.o
BIN
builds/push.o
Binary file not shown.
Binary file not shown.
BIN
builds/rotate.o
BIN
builds/rotate.o
Binary file not shown.
BIN
builds/special_sorts_3_5.o
Normal file
BIN
builds/special_sorts_3_5.o
Normal file
Binary file not shown.
BIN
builds/stop.o
BIN
builds/stop.o
Binary file not shown.
BIN
builds/swap.o
BIN
builds/swap.o
Binary file not shown.
@@ -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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user