-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_sort_five.c
29 lines (27 loc) · 1.2 KB
/
ft_sort_five.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sort_five.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: flfische <flfische@student.42heilbronn. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/05 18:48:01 by flfische #+# #+# */
/* Updated: 2024/04/10 17:05:36 by flfische ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_push_swap.h"
void ft_sort_five(t_push_swap *ps)
{
while (ps->a.len > 3)
{
if (ps->a.stack[0] == 0 || (ps->a.stack[0] == 1 && ps->input.len == 5))
ft_push_b(ps);
else
ft_rot_a(ps);
}
ft_sort_three(ps);
if (ps->input.len == 5 && ps->b.stack[0] < ps->b.stack[1])
ft_swap_b(ps);
ft_push_a(ps);
ft_push_a(ps);
}