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

@@ -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)
{
}
*/