-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_bonus.c
50 lines (46 loc) · 1.69 KB
/
main_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yzaytoun <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 19:33:39 by yzaytoun #+# #+# */
/* Updated: 2023/04/21 17:05:01 by yzaytoun ### ########.fr */
/* */
/* ************************************************************************** */
#include "include/pushswap_bonus.h"
static void ft_checkstack(t_list *a, t_list *b)
{
if (ft_issorted(a, ASC) == TRUE && ft_isempty(b))
ft_printf("OK\n");
else
ft_printf("KO\n");
}
int main(int ac, char **av)
{
t_stack *stack_a;
t_stack *stack_b;
if (ac > 1 && ac < ARG_MAX)
{
stack_a = ft_create_stack(1);
stack_b = ft_create_stack(2);
ft_initiatestack(&stack_a->stack, av);
if (ft_checkduplicates(stack_a->stack) != FALSE)
{
ft_putstr_fd("Error", STDERR_FILENO);
return (EXIT_FAILURE);
}
ft_printf("Total instructions = %d\n", ft_getline(stack_a, stack_b));
ft_printstack(stack_a);
ft_printstack(stack_b);
ft_checkstack(stack_a->stack, stack_b->stack);
ft_free(&stack_a, &stack_b, NULL);
}
else
{
ft_putstr_fd("Error\n", STDERR_FILENO);
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}