setting up the searching path if i start from the top or from the bot need to be testing out

This commit is contained in:
Maoake
2025-12-23 10:08:33 +00:00
parent e06a51e034
commit a44b878625
3 changed files with 56 additions and 1 deletions

View File

@@ -12,6 +12,59 @@
#include "push_swap.h"
int path_to_end(t_stacks *piles, int max_range, int range)
{
t_stack *tmp;
int i;
int first_pass;
tmp = piles->a;
tmp = tmp->previous;
i = 0;
first_pass = 1
while (first_pass || tmp != piles->a->previous)
{
first_pass = 0;
if (in_range(tmp->value, max_range, range))
tmp = piles->a->previous;
tmp = tmp->previous;
i++;
}
return (i);
}
int path_to_start(t_stacks *piles, int max_range, int range)
{
t_stack *tmp;
int i;
int first_pass;
tmp = piles ->a;
i = 0;
first_pass = 1;
while (first_pass || tmp != piles->a)
{
first_pass = 0;
if (in_range(tmp->value, max_range, range))
tmp = piles->a;
tmp = tmp->next;
i++;
}
return (i);
}
int wich_path(t_stacks *piles, int max_range, int range)
{
int path_start;
int path_end;
path_start = path_to_start(piles, max_range, range);
path_end = path_to_end(piles, max_range, range);
if (path_start < path_end)
return (1);
return (0);
}
void bucket_algo(void)
{
return ;