finish to switch

This commit is contained in:
Maoake Teriierooiterai
2026-01-16 11:56:00 +01:00
parent a3a462a515
commit 3887e3b4a5
7 changed files with 28 additions and 528 deletions

View File

@@ -20,8 +20,8 @@ static int is_border_a(int value, t_stacks *stacks)
if (!stacks->a)
return (1);
tmp = assign_stack(stacks, 'a');
if ((value < tmp->value && check_order(tmp))
|| (value > tmp->value && value > tmp->previous->value
if ((value < tmp->index && check_order(tmp))
|| (value > tmp->index && value > tmp->previous->index
&& check_order(stacks->a)))
return (1);
return (0);
@@ -34,12 +34,12 @@ int move_left_to_right(int value, t_stacks *stacks, int is_move)
i = 0;
tmp = assign_stack(stacks, 'a');
while (value > tmp->value && !is_move)
while (value > tmp->index && !is_move)
{
tmp = tmp->next;
i++;
}
while (value > stacks->a->value && is_move)
while (value > stacks->a->index && is_move)
ra(stacks);
return (i);
}
@@ -51,12 +51,12 @@ int move_right_to_left(int value, t_stacks *stacks, int is_move)
tmp = assign_stack(stacks, 'a');
i = 0;
while (value < tmp->previous->value && !is_move)
while (value < tmp->previous->index && !is_move)
{
tmp = tmp->previous;
i++;
}
while (value < stacks->a->previous->value && is_move)
while (value < stacks->a->previous->index && is_move)
rra(stacks);
return (i);
}

View File

@@ -28,7 +28,7 @@ static int path_to_end(t_stacks *stacks, int max_range, int range, char c)
while (first_pass || tmp != start->previous)
{
first_pass = 0;
if (in_range(tmp->value, max_range, range))
if (in_range(tmp->index, max_range, range))
tmp = start;
tmp = tmp->previous;
i++;
@@ -50,7 +50,7 @@ static int path_to_start(t_stacks *stacks, int max_range, int range, char c)
while (first_pass || tmp != start)
{
first_pass = 0;
if (in_range(tmp->value, max_range, range))
if (in_range(tmp->index, max_range, range))
{
tmp = start->previous;
}
@@ -76,12 +76,12 @@ void normal_move_path(t_stacks *stacks, t_tab *one_preset, int range)
{
if (wich_path(stacks, one_preset->max_range, range, 'b'))
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
while (!in_range(stacks->b->index, one_preset->max_range, range))
rb(stacks);
}
else
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
while (!in_range(stacks->b->index, one_preset->max_range, range))
{
rrb(stacks);
}
@@ -97,14 +97,14 @@ int get_pre_move_b(t_stacks *stacks, t_tab *one_preset, int range)
tmp = assign_stack(stacks, 'b');
if (wich_path(stacks, one_preset->max_range, range, 'b'))
{
while (!in_range(tmp->value, one_preset->max_range, range))
while (!in_range(tmp->index, one_preset->max_range, range))
{
i++;
tmp = tmp->next;
}
}
else
while (!in_range(tmp->value, one_preset->max_range, range))
while (!in_range(tmp->index, one_preset->max_range, range))
{
i++;
tmp = tmp->previous;

View File

@@ -81,7 +81,7 @@ void push_range_to_b(t_stacks *stacks, t_tab *one_preset, int range)
path_rr_rrr(value, stacks, one_preset, range);
}
normal_move_path(stacks, one_preset, range);
move_ra_rra(stacks->b->value, stacks);
move_ra_rra(stacks->b->index, stacks);
pa(stacks);
put_in_order_ra_rra(stacks);
one_preset->nb_in--;

View File

@@ -21,13 +21,13 @@ int get_value_finded(t_stacks *stacks, t_tab *one_preset, int range)
tmp = assign_stack(stacks, 'b');
if (wich_path(stacks, one_preset->max_range, range, 'b'))
{
while (!in_range(tmp->value, one_preset->max_range, range))
while (!in_range(tmp->index, one_preset->max_range, range))
tmp = tmp->next;
}
else
while (!in_range(tmp->value, one_preset->max_range, range))
while (!in_range(tmp->index, one_preset->max_range, range))
tmp = tmp->previous;
value = tmp->value;
value = tmp->index;
return (value);
}

View File

@@ -19,13 +19,13 @@ int get_first_lower(t_stack *first)
int pass;
tmp = first;
lower = tmp->value;
lower = tmp->index;
pass = 1;
while (tmp != first || pass == 1)
{
pass = 0;
if (lower > tmp->value)
lower = tmp->value;
if (lower > tmp->index)
lower = tmp->index;
tmp = tmp->next;
}
return (lower);
@@ -43,9 +43,9 @@ int get_next_lower(t_stack *first, int old_lower)
while (tmp != first || skip_first)
{
skip_first = 0;
if (old_lower < tmp->value && tmp->value <= next_lower)
if (old_lower < tmp->index && tmp->index <= next_lower)
{
next_lower = tmp->value;
next_lower = tmp->index;
if (next_lower == -2147483648)
return (next_lower);
}
@@ -96,7 +96,7 @@ int get_number_in_range(int max_range, t_stack *a, int range)
while (tmp != first || pass == 1)
{
pass = 0;
if (in_range(tmp->value, max_range, range))
if (in_range(tmp->index, max_range, range))
nb_in++;
tmp = tmp->next;
}

View File

@@ -20,13 +20,13 @@ static int get_max_number(t_stack *first)
t_stack *a;
a = first;
max = a->value;
max = a->index;
pass = 1;
while (a != first || pass == 1)
{
pass = 0;
if (max < a->value)
max = a->value;
if (max < a->index)
max = a->index;
a = a->next;
}
return (max);
@@ -39,13 +39,13 @@ static int get_min_number(t_stack *first)
int pass;
a = first;
min = a->value;
min = a->index;
pass = 1;
while (a != first || pass == 1)
{
pass = 0;
if (min > a->value)
min = a->value;
if (min > a->index)
min = a->index;
a = a->next;
}
return (min);