-
Notifications
You must be signed in to change notification settings - Fork 0
/
less_then_6.c
69 lines (65 loc) · 2.2 KB
/
less_then_6.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* less_then_6.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ajakob <ajakob@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/16 15:38:54 by ajakob #+# #+# */
/* Updated: 2023/09/01 16:24:47 by ajakob ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void if_three(int *a, int *a_len, int plus)
{
if (a[0] == 2 + plus && a[1] == 1 + plus
&& a[2] == 0 + plus
&& s(a, a_len) && rr(a, a_len))
ft_printf("sa\nrra\n");
else if (a[0] == 2 + plus && a[1] == 0 + plus
&& a[2] == 1 + plus
&& r(a, a_len))
ft_printf("ra\n");
else if (a[0] == 1 + plus && a[1] == 0 + plus
&& a[2] == 2 + plus && s(a, a_len))
ft_printf("sa\n");
else if (a[0] == 1 + plus && a[1] == 2 + plus
&& a[2] == 0 + plus && rr(a, a_len))
ft_printf("rra\n");
else if (a[0] == 0 + plus && a[1] == 2 + plus
&& a[2] == 1 + plus
&& r(a, a_len) && s(a, a_len) && rr(a, a_len))
ft_printf("ra\nsa\nrra\n");
}
void if_four(int *a, int *b, int *a_len, int *b_len)
{
if (a[0] == 0 && p(a, b, a_len, b_len))
{
ft_printf("pb\n");
if_three(a, a_len, 1);
p(b, a, b_len, a_len);
ft_printf("pa\n");
}
else if (r(a, a_len))
ft_printf("ra\n");
}
void if_five(int *a, int *b, int *a_len, int *b_len)
{
if (*b_len == 2 && a[0] == 2 && a[1] == 3
&& a[2] == 4 && b[0] == 1 && b[1] == 0)
{
p(b, a, b_len, a_len);
p(b, a, b_len, a_len);
ft_printf("pa\npa\n");
}
else if ((a[0] == 0 || a[0] == 1) && p(a, b, a_len, b_len))
ft_printf("pb\n");
else if (*a_len == 3)
{
if_three(a, a_len, 2);
if (b[0] == 0 && s(b, b_len))
ft_printf("sb\n");
}
else if (r(a, a_len))
ft_printf("ra\n");
}