Skip to content

Commit

Permalink
norm and evaluator has been validated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Felipe Dalcin Stieven committed Feb 23, 2024
1 parent 8ec825a commit 1ac79f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 115 deletions.
5 changes: 2 additions & 3 deletions includes/push_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* push_swap.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gfantoni <gfantoni@student.42.fr> +#+ +:+ +#+ */
/* By: josfelip <josfelip@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/30 10:52:24 by josfelip #+# #+# */
/* Updated: 2024/02/22 19:38:26 by gfantoni ### ########.fr */
/* Updated: 2024/02/23 12:17:15 by josfelip ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -64,7 +64,6 @@ void push_bst_indexing(t_bst **bst, t_list_push **a);
void push_bst_in_order_static(t_bst *node, int index);

// 03_moves.c
void push_baby_moves(t_list_push **a, t_list_push **b);
void push_gateway(enum e_op op, t_list_push **a, t_list_push **b);
void push_lstadd_front(t_list_push **lst, t_list_push *new);
t_list_push *push_lst_n_1(t_list_push *lst);
Expand Down
71 changes: 2 additions & 69 deletions sources/00_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* 00_main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gfantoni <gfantoni@student.42.fr> +#+ +:+ +#+ */
/* By: josfelip <josfelip@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/30 10:52:11 by josfelip #+# #+# */
/* Updated: 2024/02/22 19:30:45 by gfantoni ### ########.fr */
/* Updated: 2024/02/23 12:21:27 by josfelip ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -24,86 +24,19 @@ int main(int argc, char *argv[])
b = NULL;
push_pre_user_input_validation(&argc, &argv);
push_user_input_validation(argc, argv, &bst);
if (DEBUG == 1) // _01_user_input_validation.py
push_safe_exit(0, &a, &b, &bst);
push_fill_stack(&a, argc, argv);
push_free_split(argv);
if (push_is_sorted(a))
push_safe_exit(0, &a, &b, &bst);
push_bst_indexing(&bst, &a);
push_lst_indexing(a, bst);
if (DEBUG == 2) // _02_indexing.py
{
push_lstprintf_index(a);
push_safe_exit(0, &a, &b, &bst);
}
if (DEBUG == 3) // _03_moves.py
{
push_baby_moves(&a, &b);
push_safe_exit(0, &a, &b, &bst);
}
push_only_swap_or_tiny_sort(&a, &b, &bst);
push_all_save_three(&a, &b);
push_tiny_sort(&a);
if (DEBUG == 4) // _04_pre_sort.py
{
push_lstprintf_value(a);
if (b != NULL)
push_lstprintf_value(b);
push_safe_exit(0, &a, &b, &bst);
}
push_target_pos(a, b);
if (DEBUG == 5) // _05_target_position.py
{
push_lstprintf_target_pos(b);
push_safe_exit(0, &a, &b, &bst);
}
push_comp_cost(a, b);
if (DEBUG == 6) // _06_comp_cost.py
{
push_lstprintf_cost(b);
push_safe_exit(0, &a, &b, &bst);
}
push_cheapest_move(b, rotations);
if (DEBUG == 7) // _07_cheapest_move.py
{
ft_printf("[%d,%d]\n", rotations[0], rotations[1]);
push_safe_exit(0, &a, &b, &bst);
}
push_sort(&a, &b, rotations);
if (DEBUG == 8) // _08_sort.py
{
push_lstprintf_index(a);
ft_printf("\n");
push_lstprintf_index(b);
ft_printf("\n");
push_safe_exit(0, &a, &b, &bst);
}
push_swap(&a, &b, rotations);
if (DEBUG == 9) // _09_push_swap.py
{
push_lstprintf_index(a);
ft_printf("\n");
push_lstprintf_index(b);
ft_printf("\n");
push_safe_exit(0, &a, &b, &bst);
}
push_dial(&a);
if (DEBUG == 10) // _10_dial.py
{
push_lstprintf_index(a);
ft_printf("\n");
push_lstprintf_index(b);
ft_printf("\n");
push_safe_exit(0, &a, &b, &bst);
}
if (DEBUG == 11) // _11_split.py
{
push_lstprintf_index(a);
ft_printf("\n");
push_lstprintf_index(b);
ft_printf("\n");
push_safe_exit(0, &a, &b, &bst);
}
push_safe_exit(0, &a, &b, &bst);
}
42 changes: 1 addition & 41 deletions sources/03_moves.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,12 @@
/* By: josfelip <josfelip@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/22 15:03:18 by gfantoni #+# #+# */
/* Updated: 2024/02/22 15:30:44 by josfelip ### ########.fr */
/* Updated: 2024/02/23 12:16:58 by josfelip ### ########.fr */
/* */
/* ************************************************************************** */

#include "../includes/push_swap.h"

void push_baby_moves(t_list_push **a, t_list_push **b) // REMOVE BEFORE GRADE
{
int i;

push_gateway(RRA, a, b);
push_lstprintf_value(*a);
push_gateway(RA, a, b);
push_lstprintf_value(*a);
push_gateway(SA, a, b);
push_lstprintf_value(*a);
push_gateway(SA, a, b);
push_lstprintf_value(*a);
i = 0;
while (i++ < 6)
push_gateway(PB, a, b);
push_lstprintf_value(*b);
push_gateway(RB, a, b);
push_lstprintf_value(*b);
push_gateway(RRB, a, b);
push_lstprintf_value(*b);
push_gateway(SB, a, b);
push_lstprintf_value(*b);
push_gateway(SB, a, b);
push_lstprintf_value(*b);
i = 0;
while (i++ < 3)
push_gateway(PA, a, b);
push_lstprintf_value(*a);
push_lstprintf_value(*b);
push_gateway(RR, a, b);
push_lstprintf_value(*a);
push_lstprintf_value(*b);
push_gateway(RRR, a, b);
push_lstprintf_value(*a);
push_lstprintf_value(*b);
push_gateway(SS, a, b);
push_lstprintf_value(*a);
push_lstprintf_value(*b);
}

void push_gateway(enum e_op op, t_list_push **a, t_list_push **b)
{
if (op == SA)
Expand Down
5 changes: 3 additions & 2 deletions sources/09_push_swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* 09_push_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gfantoni <gfantoni@student.42.fr> +#+ +:+ +#+ */
/* By: josfelip <josfelip@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/22 15:06:28 by gfantoni #+# #+# */
/* Updated: 2024/02/22 15:06:41 by gfantoni ### ########.fr */
/* Updated: 2024/02/23 12:21:37 by josfelip ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,4 +21,5 @@ void push_swap(t_list_push **a, t_list_push **b, int *rotations)
push_cheapest_move(*b, rotations);
push_sort(a, b, rotations);
}
push_dial(&a);
}

0 comments on commit 1ac79f3

Please sign in to comment.