mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
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:
@@ -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 ;
|
||||
|
||||
Reference in New Issue
Block a user