/* ************************************************************************** */ /* */ /* ::: o_ :::::: ::: */ /* utils.c :+: / :+::+: :+: */ /* +:+ > +:++:+ +:+ */ /* By: whaffman +#+ +:+ +#++#++:++#++ */ /* +#+ +#+#+ +#++#+ +#+ \o/ */ /* Created: 2024/11/10 14:44:51 by whaffman #+#+# #+#+# #+# #+# | */ /* Updated: 2024/11/17 17:41:19 by whaffman ### ### ### ### / \ */ /* */ /* ************************************************************************** */ #include "libft.h" #include "push_swap.h" int index_of(int number, t_list *stack) { int i; i = 0; while (stack) { if (*(int *) stack->content == number) return (i); stack = stack->next; i++; } return (-1); } int ft_abs(int a) { if (a >= 0) return (a); return (-a); } int ft_max(int a, int b) { if (a > b) return (a); return (b); } int count_gt(int n, t_list *stack) { int count; count = 0; while (stack) { if (*(int *) stack->content < n) count++; stack = stack->next; } return (count); }