mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
modifying some folders
This commit is contained in:
2
Makefile
2
Makefile
@@ -93,7 +93,7 @@ NAME_BONUS = checker
|
||||
|
||||
.PHONY: all clean fclean re bonus
|
||||
|
||||
all: $(NAME)
|
||||
all: $(NAME) $(NAME_BONUS)
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#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;
|
||||
@@ -41,21 +41,20 @@ static int path_to_end(t_stacks *stacks, int max_range, int range, char c)
|
||||
static int path_to_start(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 = (stacks, c);
|
||||
start = (stacks, c);
|
||||
i = 0;
|
||||
first_pass = 1;
|
||||
while (first_pass || tmp != stacks->b)
|
||||
while (first_pass || tmp != start)
|
||||
{
|
||||
first_pass = 0;
|
||||
if (in_range(tmp->value, max_range, range))
|
||||
{
|
||||
tmp = stacks->b->previous;
|
||||
tmp = start->previous;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
i++;
|
||||
@@ -95,8 +94,7 @@ void bucket_algo(t_stacks *stacks, t_tab *preset, int range)
|
||||
t_tab *tmp;
|
||||
|
||||
tmp = preset;
|
||||
while (stacks->a)
|
||||
pb(stacks);
|
||||
medium_pre_sort(stacks, preset, range);
|
||||
while (preset)
|
||||
{
|
||||
push_range_to_b(stacks, preset, range);
|
||||
|
||||
@@ -11,6 +11,41 @@
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "push_swap.h"
|
||||
#include "medium_headers.h"
|
||||
|
||||
static void medium_pus_to_a(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, '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++;
|
||||
}
|
||||
}
|
||||
|
||||
void medium_pre_sort(t_stacks *stacks, t_tab *preset, int range)
|
||||
{
|
||||
t_tab *tmp;
|
||||
|
||||
tmp = preset;
|
||||
while (preset)
|
||||
{
|
||||
medium_pus_to_a(stacks, tmp, range);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void sort_from_left(t_stacks *stacks)
|
||||
{
|
||||
@@ -47,3 +82,14 @@ void sort_from_right(t_stacks *stacks)
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
t_stack *assign_stack(t_stacks *stacks, char c)
|
||||
{
|
||||
t_stack *tmp;
|
||||
|
||||
if (c == 'a')
|
||||
tmp = stacks->a;
|
||||
else
|
||||
tmp = stacks->b;
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ void bucket_algo(t_stacks *stacks, t_tab *preset, int range);
|
||||
void sort_from_left(t_stacks *stacks);
|
||||
void sort_from_right(t_stacks *stacks);
|
||||
void push_range_to_b(t_stacks *stacks, t_tab *one_preset, int range);
|
||||
void medium_pre_sort(t_stacks *stacks, t_tab *preset, int range);
|
||||
t_stack *assign_stack(t_stacks *stacks, char c);
|
||||
/* MEDIUM UTILS FILES */
|
||||
int range_bucket(t_stack *first);
|
||||
int get_first_lower(t_stack *first);
|
||||
|
||||
Reference in New Issue
Block a user