-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort_5_xtra.c
47 lines (42 loc) · 1.43 KB
/
sort_5_xtra.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sort_5_xtra.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lstorey <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/26 10:05:00 by lstorey #+# #+# */
/* Updated: 2024/03/26 16:26:59 by lstorey ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
t_ps_list *find_second_lowest(t_ps_list **stack_a)
{
t_ps_list *tmp;
t_ps_list *second_lowest;
tmp = (*stack_a);
second_lowest = (*stack_a);
while (tmp->next)
{
if (tmp->next->index < tmp->index && tmp->index != 0)
second_lowest = tmp->next;
tmp = tmp->next;
}
return (second_lowest);
}
int second_distance_to_top(t_ps_list **stack_a)
{
int distance;
t_ps_list *tmp;
distance = 0;
tmp = (*stack_a);
while (tmp)
{
if (tmp->index != 1)
distance++;
else
return (distance);
tmp = tmp->next;
}
return (distance);
}