special sort for 5 ok

This commit is contained in:
hugogogo
2021-09-27 02:13:21 +02:00
parent bb2a08833a
commit 6a93eda973
15 changed files with 114 additions and 61 deletions

View File

@@ -1,22 +1,5 @@
#include "push_swap.h"
// size is initialized to 1 because the loop check the next element, so it will end one step before reaching it
// it checks the next one to avoid handle the first one with ->limit set to 1
int sublist_size(t_stack *list)
{
int size;
if (list == NULL)
return (0);
size = 1;
while (list->next != NULL && list->next->limit != 1)
{
list = list->next;
size++;
}
return (size);
}
int nbr_element_smaller(t_stack *list, int size, int pivot)
{
int nbr;
@@ -126,7 +109,7 @@ void recursif_sort(t_stack **a, t_stack **b, t_list *solution)
else
{
// sort_big(a, b, solution)
// bubble_sort(a, b, solution)
mini_sort(a, solution);
// minisort(a, solution);
if (sublist_size(*b) > 4)
@@ -143,10 +126,8 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
{
if (sublist_size(*a) <= 3)
special_sort_3(a, solution);
/*
else if (sublist_size(*a) <= 5)
special_sort_5(a, b, solution);
*/
else
recursif_sort(a, b, solution);
}