-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
52 lines (47 loc) · 1.64 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rileone <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/22 13:55:06 by rileone #+# #+# */
/* Updated: 2024/05/03 18:42:35 by rileone ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
static void minisolver(t_stacks *stacks)
{
int len;
len = ft_dll_size(stacks->a);
if (ft_dll_check_if_ordered(stacks->a) == 1)
free_minisolver_heap(stacks);
if (len == 2)
minisolver2(stacks->a, 'a');
else if (len == 3)
minisolver3(stacks);
else if (len == 4)
minisolver4(stacks);
else if (len == 5)
minisolver5(stacks);
}
int main(int ac, char **av)
{
t_stacks stacks;
if (ac < 2)
return (0);
stacks = (t_stacks){0};
ft_init_(ac, av, &stacks);
if (stacks.input_arr_len < LIS_INPUT_LIMIT)
minisolver(&stacks);
else
{
if (!ft_generate_non_lis(&stacks))
return (ft_free_stacks(&stacks), error_fn(), 0);
ft_move_non_lis(&stacks);
ft_sortback(&stacks);
}
ft_rotate_until_ordered(&stacks);
ft_free_stacks(&stacks);
return (0);
}