delete condition to add operation in t_stacks

This commit is contained in:
2026-01-08 13:59:09 +00:00
parent 2ba9029955
commit bb39e7d0ec
4 changed files with 26 additions and 48 deletions

View File

@@ -6,7 +6,7 @@
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */ /* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 15:09:40 by mteriier #+# #+# */ /* Created: 2025/12/08 15:09:40 by mteriier #+# #+# */
/* Updated: 2026/01/08 13:52:01 by dgaillet ### ########lyon.fr */ /* Updated: 2026/01/08 13:57:56 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -30,9 +30,7 @@ void pa(t_stacks *stacks)
stacks->b = stacks->b->next; stacks->b = stacks->b->next;
} }
stack_add_front(&(stacks->a), b_push); stack_add_front(&(stacks->a), b_push);
if (stacks->bench)
stacks->pa++; stacks->pa++;
else
write(1, "pa\n", 3); write(1, "pa\n", 3);
} }
@@ -52,8 +50,6 @@ void pb(t_stacks *stacks)
stacks->a = stacks->a->next; stacks->a = stacks->a->next;
} }
stack_add_front(&(stacks->b), a_push); stack_add_front(&(stacks->b), a_push);
if (stacks->bench)
stacks->pb++; stacks->pb++;
else
write(1, "pb\n", 3); write(1, "pb\n", 3);
} }

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:43:45 by dgaillet #+# #+# */ /* Created: 2025/12/08 14:43:45 by dgaillet #+# #+# */
/* Updated: 2026/01/08 13:52:33 by dgaillet ### ########lyon.fr */ /* Updated: 2026/01/08 13:57:27 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -17,9 +17,7 @@ void rra(t_stacks *stacks)
{ {
if (stacks && stacks->a && stacks->a->previous) if (stacks && stacks->a && stacks->a->previous)
stacks->a = stacks->a->previous; stacks->a = stacks->a->previous;
if (stacks->bench)
stacks->rra++; stacks->rra++;
else
write(1, "rra\n", 4); write(1, "rra\n", 4);
} }
@@ -27,9 +25,7 @@ void rrb(t_stacks *stacks)
{ {
if (stacks && stacks->b && stacks->b->previous) if (stacks && stacks->b && stacks->b->previous)
stacks->b = stacks->b->previous; stacks->b = stacks->b->previous;
if (stacks->bench)
stacks->rrb++; stacks->rrb++;
else
write(1, "rrb\n", 4); write(1, "rrb\n", 4);
} }
@@ -39,8 +35,6 @@ void rrr(t_stacks *stacks)
stacks->b = stacks->b->previous; stacks->b = stacks->b->previous;
if (stacks && stacks->a && stacks->a->previous) if (stacks && stacks->a && stacks->a->previous)
stacks->a = stacks->a->previous; stacks->a = stacks->a->previous;
if (stacks->bench)
stacks->rrr++; stacks->rrr++;
else
write(1, "rrr\n", 4); write(1, "rrr\n", 4);
} }

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:32:10 by dgaillet #+# #+# */ /* Created: 2025/12/08 14:32:10 by dgaillet #+# #+# */
/* Updated: 2026/01/08 13:52:59 by dgaillet ### ########lyon.fr */ /* Updated: 2026/01/08 13:57:47 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -17,9 +17,7 @@ void ra(t_stacks *stacks)
{ {
if (stacks && stacks->a && stacks->a->next) if (stacks && stacks->a && stacks->a->next)
stacks->a = stacks->a->next; stacks->a = stacks->a->next;
if (stacks->bench)
stacks->ra++; stacks->ra++;
else
write(1, "ra\n", 3); write(1, "ra\n", 3);
} }
@@ -27,9 +25,7 @@ void rb(t_stacks *stacks)
{ {
if (stacks && stacks->b && stacks->b->next) if (stacks && stacks->b && stacks->b->next)
stacks->b = stacks->b->next; stacks->b = stacks->b->next;
if (stacks->bench)
stacks->rb++; stacks->rb++;
else
write(1, "rb\n", 3); write(1, "rb\n", 3);
} }
@@ -39,8 +35,6 @@ void rr(t_stacks *stacks)
stacks->a = stacks->a->next; stacks->a = stacks->a->next;
if (stacks && stacks->b && stacks->b->next) if (stacks && stacks->b && stacks->b->next)
stacks->b = stacks->b->next; stacks->b = stacks->b->next;
if (stacks->bench)
stacks->rr++; stacks->rr++;
else
write(1, "rr\n", 3); write(1, "rr\n", 3);
} }

View File

@@ -6,7 +6,7 @@
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */ /* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:48:44 by mteriier #+# #+# */ /* Created: 2025/12/08 14:48:44 by mteriier #+# #+# */
/* Updated: 2026/01/08 13:53:40 by dgaillet ### ########lyon.fr */ /* Updated: 2026/01/08 13:58:13 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -24,9 +24,7 @@ void sa(t_stacks *stacks)
stock = a->value; stock = a->value;
a->value = a->next->value; a->value = a->next->value;
a->next->value = stock; a->next->value = stock;
if (stacks->bench)
stacks->sa++; stacks->sa++;
else
write(1, "sa\n", 3); write(1, "sa\n", 3);
} }
@@ -41,9 +39,7 @@ void sb(t_stacks *stacks)
stock = b->value; stock = b->value;
b->value = b->next->value; b->value = b->next->value;
b->next->value = stock; b->next->value = stock;
if (stacks->bench)
stacks->sb++; stacks->sb++;
else
write(1, "sb\n", 3); write(1, "sb\n", 3);
} }
@@ -69,8 +65,6 @@ void ss(t_stacks *stacks)
a->value = a->next->value; a->value = a->next->value;
a->next->value = stock; a->next->value = stock;
} }
if (stacks->bench)
stacks->ss++; stacks->ss++;
else
write(1, "ss\n", 3); write(1, "ss\n", 3);
} }