-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_move_to.c
53 lines (45 loc) · 1.36 KB
/
stack_move_to.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_move_to.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: coskelet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/07 17:15:49 by coskelet #+# #+# */
/* Updated: 2022/03/07 17:46:14 by coskelet ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static short try_put_b(t_stacks *st)
{
if (move_rback(st))
return(0);
if (move_back(st))
return (0);
exec_cmd(st, "pb", 1);
find_short_boundaries(st);
return (1);
}
void move_to_b(t_stacks *st)
{
int i;
i = 0;
while (!try_put_b(st))
i++;
return ;
}
static short try_put_a(t_stacks *st)
{
if (move_back(st))
return (0);
exec_cmd(st, "pa", 1);
return (1);
}
void move_to_a(t_stacks *st)
{
int i;
i = 0;
while (!try_put_a(st))
i++;
return ;
}