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;
|
a = stacks->a;
|
||||||
while (i < sorted)
|
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);
|
return (i);
|
||||||
a = a->previous;
|
a = a->previous;
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ int calcul_range(int value, int range)
|
|||||||
{
|
{
|
||||||
int max_range;
|
int max_range;
|
||||||
|
|
||||||
|
|
||||||
max_range = 0;
|
max_range = 0;
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
while (max_range > value)
|
while (max_range > value)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ int range_bucket(t_stack *first)
|
|||||||
int sqrt;
|
int sqrt;
|
||||||
|
|
||||||
len = stack_len(first);
|
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);
|
sqrt = my_sqrt(len);
|
||||||
if (diff / sqrt < 2)
|
if (diff / sqrt < 2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,5 +25,4 @@ void flags(int pos, char **argv, t_stacks *piles)
|
|||||||
adaptive(piles);
|
adaptive(piles);
|
||||||
else
|
else
|
||||||
adaptive(piles);
|
adaptive(piles);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#ifndef FLAGS_H
|
#ifndef FLAGS_H
|
||||||
# define FLAGS_H
|
# define FLAGS_H
|
||||||
|
|
||||||
void simple(t_stacks *piles);
|
void simple(t_stacks *piles);
|
||||||
void medium(t_stacks *piles);
|
void medium(t_stacks *piles);
|
||||||
void complex(t_stacks *piles);
|
void complex(t_stacks *piles);
|
||||||
void adaptive(t_stacks *piles);
|
void adaptive(t_stacks *piles);
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
#ifndef PARSING_H
|
#ifndef PARSING_H
|
||||||
# define 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_stacks2(int *tab, int len);
|
||||||
t_stacks *init_big_stacks(int argc, char **argv);
|
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
|
#endif
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ int test1(int argc, char **argv)
|
|||||||
preset = get_tabs(piles->a, range_bucket(piles->a));
|
preset = get_tabs(piles->a, range_bucket(piles->a));
|
||||||
bucket_algo(piles, preset, range_bucket(piles->a));
|
bucket_algo(piles, preset, range_bucket(piles->a));
|
||||||
}
|
}
|
||||||
if (piles->a)
|
free_all(piles);
|
||||||
stack_clear_all(piles->a, piles->a);
|
|
||||||
if (piles->b)
|
|
||||||
stack_clear_all(piles->b, piles->b);
|
|
||||||
free(piles);
|
free(piles);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user