/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* swap.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mteriier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/12/08 14:48:44 by mteriier #+# #+# */ /* Updated: 2026/01/08 13:53:40 by dgaillet ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" #include void sa(t_stacks *stacks) { t_stack *a; int stock; if (!stacks || !stacks->a || !stacks->a->next) return ; a = stacks->a; stock = a->value; a->value = a->next->value; a->next->value = stock; if (stacks->bench) stacks->sa++; else write(1, "sa\n", 3); } void sb(t_stacks *stacks) { t_stack *b; int stock; if (!stacks || !stacks->b || !stacks->b->next) return ; b = stacks->b; stock = b->value; b->value = b->next->value; b->next->value = stock; if (stacks->bench) stacks->sb++; else write(1, "sb\n", 3); } void ss(t_stacks *stacks) { t_stack *b; t_stack *a; int stock; if (!stacks) return ; if (stacks->b && stacks->b->next) { b = stacks->b; stock = b->value; b->value = b->next->value; b->next->value = stock; } if (stacks->a && stacks->a->next) { a = stacks->a; stock = a->value; a->value = a->next->value; a->next->value = stock; } if (stacks->bench) stacks->ss++; else write(1, "ss\n", 3); }