modifying some preset for the tabs and adding some functions in the main for do the test

This commit is contained in:
Maoake
2025-12-22 11:06:34 +00:00
parent a7cbd18db6
commit e563d663ec
7 changed files with 141 additions and 20 deletions

View File

@@ -0,0 +1,65 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_medium_two.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mteriier <mteriier@student.lyon42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/22 09:36:56 by mteriier #+# #+# */
/* Updated: 2025/12/22 09:38:19 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int get_max_number(t_stack *first)
{
int max;
t_stack *a;
a = first;
max = a->value;
while (a->next != first)
{
if (max < a->value)
max = a->value;
a = a->next;
}
return (max);
}
int get_min_number(t_stack *first)
{
int min;
t_stack *a;
a = first;
min = a->value;
while (a->next != first)
{
if (min > a->value)
min = a->value;
a = a->next;
}
return (min);
}
int my_sqrt(int nb)
{
int i;
if (nb < 1)
return (0);
i = 0;
while (i * i <= nb)
i++;
return (i);
}
int range_bucket(t_stack *first)
{
int len;
len = stack_len(first);
return ((get_max_number(first) - get_min_number(first)) / my_sqrt(len));
}