Skip to content

Commit

Permalink
push_swap
Browse files Browse the repository at this point in the history
  • Loading branch information
Ana Laura Da Silva Volkmann committed Jul 19, 2024
1 parent 7187ee0 commit b8adc8c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ft_big_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/10 12:54:58 by ana-lda- #+# #+# */
/* Updated: 2024/07/19 11:18:38 by ana-lda- ### ########.fr */
/* Updated: 2024/07/19 17:13:32 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion push_swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/27 14:18:34 by ana-lda- #+# #+# */
/* Updated: 2024/07/17 14:27:53 by ana-lda- ### ########.fr */
/* Updated: 2024/07/19 15:12:16 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
16 changes: 10 additions & 6 deletions set_cost_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/16 13:38:28 by ana-lda- #+# #+# */
/* Updated: 2024/07/19 13:58:04 by ana-lda- ### ########.fr */
/* Updated: 2024/07/19 15:57:33 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -44,13 +44,17 @@ void refine_cost(t_stack *temp, t_stack **stack_a, t_stack **stack_b)

if (temp->above_median && temp->target->above_median)
{
temp->cost -= (temp->index < temp->target->index) ? temp->index : temp->target->index;
if (temp->index < temp->target->index)
temp->cost -= temp->index;
else
temp->cost -= temp->target->index;
}
else
else if (!(temp->above_median) && (!temp->target->above_median))
{
int cost_a = size_a - temp->index;
int cost_b = size_b - temp->target->index;
temp->cost -= (cost_a < cost_b) ? cost_a : cost_b;
if (size_a - temp->index < size_b - temp->target->index)
temp->cost -= size_a - temp->index;
else
temp->cost -= size_b - temp->target->index;
}
}

Expand Down
4 changes: 2 additions & 2 deletions set_targets.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ana-lda- <ana-lda-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/13 14:26:47 by ana-lda- #+# #+# */
/* Updated: 2024/07/19 12:07:23 by ana-lda- ### ########.fr */
/* Updated: 2024/07/19 16:47:21 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -85,4 +85,4 @@ void update_stack_nodes(t_stack **stack_a, t_stack **stack_b, int flag)
set_target_in_a(stack_a, stack_b);
cost_of_b(stack_a, stack_b);
}
}
}

0 comments on commit b8adc8c

Please sign in to comment.