mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
doing the norm
This commit is contained in:
@@ -24,7 +24,8 @@ static int to_insert(t_stacks *stacks, int sorted)
|
||||
a = stacks->a;
|
||||
while (i < sorted)
|
||||
{
|
||||
if (stacks->b->value > a->previous->value && stacks->b->value <= a->value)
|
||||
if (stacks->b->value > a->previous->value
|
||||
&& stacks->b->value <= a->value)
|
||||
return (i);
|
||||
a = a->previous;
|
||||
i++;
|
||||
|
||||
@@ -92,4 +92,4 @@ void push_range_to_b(t_stacks *piles, t_tab *one_preset, int range)
|
||||
sort_little_pile(piles);
|
||||
one_preset->nb_in--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ int calcul_range(int value, int range)
|
||||
{
|
||||
int max_range;
|
||||
|
||||
|
||||
max_range = 0;
|
||||
if (value < 0)
|
||||
while (max_range > value)
|
||||
|
||||
@@ -64,7 +64,7 @@ int range_bucket(t_stack *first)
|
||||
int sqrt;
|
||||
|
||||
len = stack_len(first);
|
||||
diff = (get_max_number(first) - get_min_number(first)) ;
|
||||
diff = get_max_number(first) - get_min_number(first);
|
||||
sqrt = my_sqrt(len);
|
||||
if (diff / sqrt < 2)
|
||||
{
|
||||
|
||||
@@ -25,5 +25,4 @@ void flags(int pos, char **argv, t_stacks *piles)
|
||||
adaptive(piles);
|
||||
else
|
||||
adaptive(piles);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#ifndef FLAGS_H
|
||||
# define FLAGS_H
|
||||
|
||||
void simple(t_stacks *piles);
|
||||
void simple(t_stacks *piles);
|
||||
void medium(t_stacks *piles);
|
||||
void complex(t_stacks *piles);
|
||||
void adaptive(t_stacks *piles);
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#ifndef PARSING_H
|
||||
# define PARSING_H
|
||||
|
||||
int ft_atoi(const char *nptr);
|
||||
int ft_atoi(const char *nptr);
|
||||
t_stacks *init_big_stacks2(int *tab, int len);
|
||||
t_stacks *init_big_stacks(int argc, char **argv);
|
||||
int ft_strncmp(const char *s1, const char *s2, int n);
|
||||
int ft_strncmp(const char *s1, const char *s2, int n);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,5 +28,5 @@ void free_all(t_stacks *piles)
|
||||
stack_clear_all(piles->a, piles->a);
|
||||
if (piles->b)
|
||||
stack_clear_all(piles->b, piles->b);
|
||||
free(piles);
|
||||
free(piles);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,7 @@ int test1(int argc, char **argv)
|
||||
preset = get_tabs(piles->a, range_bucket(piles->a));
|
||||
bucket_algo(piles, preset, range_bucket(piles->a));
|
||||
}
|
||||
if (piles->a)
|
||||
stack_clear_all(piles->a, piles->a);
|
||||
if (piles->b)
|
||||
stack_clear_all(piles->b, piles->b);
|
||||
free_all(piles);
|
||||
free(piles);
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user