trying some opti start to opti

This commit is contained in:
Maoake Teriierooiterai
2026-01-15 12:09:38 +01:00
parent 854d699780
commit 469320374d
5 changed files with 22 additions and 51 deletions

View File

@@ -13,25 +13,24 @@
#include "push_swap.h"
#include "medium_headers.h"
#include <stdlib.h>
#include <stdio.h>
static int path_to_end(t_stacks *stacks, int max_range, int range, char c)
{
t_stack *tmp;
t_stack *start;
int i;
int first_pass;
if (c == 'a')
tmp = stacks->a;
else
tmp = stacks->b;
tmp = assign_stack(stacks, c);
start = assign_stack(stacks, c);
tmp = tmp->previous;
i = 0;
first_pass = 1;
while (first_pass || tmp != stacks->b->previous)
while (first_pass || tmp != start->previous)
{
first_pass = 0;
if (in_range(tmp->value, max_range, range))
tmp = stacks->b;
tmp = start;
tmp = tmp->previous;
i++;
}
@@ -45,8 +44,8 @@ static int path_to_start(t_stacks *stacks, int max_range, int range, char c)
int i;
int first_pass;
tmp = (stacks, c);
start = (stacks, c);
tmp = assign_stack(stacks, c);
start = assign_stack(stacks, c);
i = 0;
first_pass = 1;
while (first_pass || tmp != start)
@@ -94,7 +93,8 @@ void bucket_algo(t_stacks *stacks, t_tab *preset, int range)
t_tab *tmp;
tmp = preset;
medium_pre_sort(stacks, preset, range);
while(stacks->a)
pb(stacks);
while (preset)
{
push_range_to_b(stacks, preset, range);

View File

@@ -77,18 +77,7 @@ void push_range_to_b(t_stacks *stacks, t_tab *one_preset, int range)
{
while (one_preset->nb_in > 0)
{
if (wich_path(stacks, one_preset->max_range, range, 'b'))
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
rb(stacks);
}
else
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
{
rrb(stacks);
}
}
normal_move_path(stacks, one_preset, range);
sort_little_pile(stacks);
one_preset->nb_in--;
}

View File

@@ -13,37 +13,19 @@
#include "push_swap.h"
#include "medium_headers.h"
static void medium_pus_to_a(t_stacks *stacks, t_tab *one_preset, int range)
void normal_move_path(t_stacks *stacks, t_tab *one_preset, int range)
{
int i;
i = 0;
while (one_preset->nb_in > i)
if (wich_path(stacks, one_preset->max_range, range, 'b'))
{
if (wich_path(stacks, one_preset->max_range, range, 'a'))
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
ra(stacks);
}
else
{
while (!in_range(stacks->b->value, one_preset->max_range, range))
rra(stacks);
}
pb(stacks);
i++;
while (!in_range(stacks->b->value, one_preset->max_range, range))
rb(stacks);
}
}
void medium_pre_sort(t_stacks *stacks, t_tab *preset, int range)
{
t_tab *tmp;
tmp = preset;
while (preset)
else
{
medium_pus_to_a(stacks, tmp, range);
tmp = tmp->next;
while (!in_range(stacks->b->value, one_preset->max_range, range))
{
rrb(stacks);
}
}
}