ajout du script de comparaison
This commit is contained in:
8
Makefile
8
Makefile
@@ -75,5 +75,13 @@ leaks: clean $(NAME)
|
|||||||
valgrind: clean $(NAME)
|
valgrind: clean $(NAME)
|
||||||
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) -p 4 67 9 76 98 7 1
|
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) -p 4 67 9 76 98 7 1
|
||||||
|
|
||||||
|
testp : clean $(NAME)
|
||||||
|
./$(NAME) -p 76 81 10 11 12 15 14 27 34 28 17 18 19 20 36 21 23 37 22 24 25 26 29 30 31 72 33 53 46 32 35 91 38 39 40 45 78 41 57 71 54 43 42 44 66 50 47 48 49 79 51 56 93 65 64 63 67 90 58 59 60 62 61 87 68 74 82 85 86 77 75 70 73 89 69 83 84 92 88 95 94 96 99 97 98 100 1 2 3 4 5 6 7 8 9 52 16 55 80 13
|
||||||
|
|
||||||
|
test : clean $(NAME)
|
||||||
|
./$(NAME) 76 81 10 11 12 15 14 27 34 28 17 18 19 20 36 21 23 37 22 24 25 26 29 30 31 72 33 53 46 32 35 91 38 39 40 45 78 41 57 71 54 43 42 44 66 50 47 48 49 79 51 56 93 65 64 63 67 90 58 59 60 62 61 87 68 74 82 85 86 77 75 70 73 89 69 83 84 92 88 95 94 96 99 97 98 100 1 2 3 4 5 6 7 8 9 52 16 55 80 13
|
||||||
|
|
||||||
|
# 83 94 28 17 18 36 20 33 39 53 23 37 22 24 45 25 29 78 26 30 31 72 46 32 35 70 38 93 50 91 40 5 41 57 71 66 92 54 67 75 65 42 43 44 74 79 47 48 49 88 51 63 7 68 87 61 82 4 90 58 59 62 60 1 85 89 96 98 100 84 69 77 73 3 86 99 97 6 2 9 8 52 80 16 55 13 76 81 10 11 12 15 14 27 34 56 21 64 95 19
|
||||||
|
|
||||||
.PHONY: all clean fclean re gcc
|
.PHONY: all clean fclean re gcc
|
||||||
|
|
||||||
|
|||||||
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
BIN
builds/push.o
BIN
builds/push.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
builds/rotate.o
BIN
builds/rotate.o
Binary file not shown.
BIN
builds/swap.o
BIN
builds/swap.o
Binary file not shown.
52
compare_pushswap.sh
Executable file
52
compare_pushswap.sh
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# usage of arguments
|
||||||
|
if [ $# -eq 3 ]
|
||||||
|
then # names = path to programs
|
||||||
|
NAME1=$1
|
||||||
|
NAME2=$2
|
||||||
|
PRGRM1=$1 # path to programs
|
||||||
|
PRGRM2=$2
|
||||||
|
SIZE=$3 # size of the list
|
||||||
|
elif [ $# -eq 5 ]
|
||||||
|
then # names given in arguments
|
||||||
|
NAME1=$1
|
||||||
|
NAME2=$3
|
||||||
|
PRGRM1=$2 # path to programs
|
||||||
|
PRGRM2=$4
|
||||||
|
SIZE=$5 # size of the list
|
||||||
|
else
|
||||||
|
echo "usage : ./compare_pushswap file1 file2 nb"
|
||||||
|
echo "or : ./compare_pushswap name1 file1 name2 file2 nb"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# range of random numbers
|
||||||
|
RANGE=100
|
||||||
|
if [ $SIZE -gt 99 ]; then RANGE=1000; fi
|
||||||
|
if [ $SIZE -gt 999 ]; then echo "size too big"; exit 0; fi
|
||||||
|
|
||||||
|
# generate the list of randoms differents numbers
|
||||||
|
LIST=($(shuf -i 0-$RANGE -n $SIZE))
|
||||||
|
echo -e "${LIST[@]}"
|
||||||
|
|
||||||
|
# player equal number of line of programm output
|
||||||
|
PLAYER1=$(./$PRGRM1 ${LIST[@]} | wc -l)
|
||||||
|
PLAYER2=$(./$PRGRM2 ${LIST[@]} | wc -l)
|
||||||
|
|
||||||
|
# colors variables
|
||||||
|
RED='\033[1;31m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
if [ $PLAYER1 -lt $PLAYER2 ]
|
||||||
|
then
|
||||||
|
COLOR1=$GREEN
|
||||||
|
COLOR2=$RED
|
||||||
|
else
|
||||||
|
COLOR1=$RED
|
||||||
|
COLOR2=$GREEN
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${COLOR1}$NAME1 : $PLAYER1${NC}"
|
||||||
|
echo -e "${COLOR2}$NAME2 : $PLAYER2${NC}"
|
||||||
@@ -39,11 +39,14 @@ void fill_solution(t_list *solution, char *sp)
|
|||||||
|
|
||||||
void print_result(t_list *result, int flag)
|
void print_result(t_list *result, int flag)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
char **part;
|
char **part;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
result = result->next->next;
|
result = result->next->next;
|
||||||
while (result)
|
while (result)
|
||||||
{
|
{
|
||||||
|
i++;
|
||||||
part = ft_split(result->content, '!');
|
part = ft_split(result->content, '!');
|
||||||
ft_printf("%s\n", part[0]);
|
ft_printf("%s\n", part[0]);
|
||||||
if (flag)
|
if (flag)
|
||||||
@@ -57,4 +60,6 @@ void print_result(t_list *result, int flag)
|
|||||||
free(part[2]);
|
free(part[2]);
|
||||||
free(part);
|
free(part);
|
||||||
}
|
}
|
||||||
|
if (flag)
|
||||||
|
ft_putnbrendl(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ void push(t_stack **dst, t_stack **src)
|
|||||||
t_stack *tmp1;
|
t_stack *tmp1;
|
||||||
t_stack *tmp2;
|
t_stack *tmp2;
|
||||||
|
|
||||||
if (!((*src)->next))
|
if (*src)
|
||||||
return ;
|
{
|
||||||
tmp1 = *src;
|
tmp1 = *src;
|
||||||
tmp2 = *dst;
|
tmp2 = *dst;
|
||||||
*src = (*src)->next;
|
*src = (*src)->next;
|
||||||
tmp1->next = tmp2;
|
tmp1->next = tmp2;
|
||||||
*dst = tmp1;
|
*dst = tmp1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_list *pa(t_stack **a, t_stack **b, t_list **solution)
|
t_list *pa(t_stack **a, t_stack **b, t_list **solution)
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ t_list *launch_algo(t_stack **a, t_stack **b, int flag)
|
|||||||
ft_lstadd_back(&solution, ft_lstnew(b));
|
ft_lstadd_back(&solution, ft_lstnew(b));
|
||||||
if (flag)
|
if (flag)
|
||||||
fill_solution(solution, "start");
|
fill_solution(solution, "start");
|
||||||
hugo_sort(a, b, solution);
|
// hugo_sort(a, b, solution);
|
||||||
|
bubble_sort(a, b, solution);
|
||||||
return (solution);
|
return (solution);
|
||||||
}
|
}
|
||||||
// bubble_sort(&a, &b, solution);
|
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ void reverse_rotate(t_stack **stack)
|
|||||||
t_stack *tmp;
|
t_stack *tmp;
|
||||||
t_stack *before;
|
t_stack *before;
|
||||||
|
|
||||||
|
if (*stack && (*stack)->next)
|
||||||
|
{
|
||||||
tmp = *stack;
|
tmp = *stack;
|
||||||
if (!tmp || !(tmp->next))
|
|
||||||
return ;
|
|
||||||
while (tmp->next)
|
while (tmp->next)
|
||||||
{
|
{
|
||||||
before = tmp;
|
before = tmp;
|
||||||
@@ -16,6 +16,7 @@ void reverse_rotate(t_stack **stack)
|
|||||||
tmp->next = *stack;
|
tmp->next = *stack;
|
||||||
*stack = tmp;
|
*stack = tmp;
|
||||||
before->next = NULL;
|
before->next = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_list *rra(t_stack **a, t_list **lst)
|
t_list *rra(t_stack **a, t_list **lst)
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ void rotate(t_stack **stack)
|
|||||||
t_stack *tmp;
|
t_stack *tmp;
|
||||||
t_stack *first;
|
t_stack *first;
|
||||||
|
|
||||||
|
if (*stack && (*stack)->next)
|
||||||
|
{
|
||||||
first = *stack;
|
first = *stack;
|
||||||
tmp = *stack;
|
tmp = *stack;
|
||||||
if (!tmp || !(tmp->next))
|
|
||||||
return ;
|
|
||||||
*stack = (*stack)->next;
|
*stack = (*stack)->next;
|
||||||
while (tmp->next)
|
while (tmp->next)
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
tmp->next = first;
|
tmp->next = first;
|
||||||
first->next = NULL;
|
first->next = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_list *ra(t_stack **a, t_list **lst)
|
t_list *ra(t_stack **a, t_list **lst)
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ void swap(t_stack **stack)
|
|||||||
{
|
{
|
||||||
t_stack *tmp;
|
t_stack *tmp;
|
||||||
|
|
||||||
|
if (*stack && (*stack)->next)
|
||||||
|
{
|
||||||
tmp = *stack;
|
tmp = *stack;
|
||||||
if (!(tmp->next))
|
|
||||||
return ;
|
|
||||||
*stack = (*stack)->next;
|
*stack = (*stack)->next;
|
||||||
tmp->next = (*stack)->next;
|
tmp->next = (*stack)->next;
|
||||||
(*stack)->next = tmp;
|
(*stack)->next = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_list *sa(t_stack **a, t_list **solution)
|
t_list *sa(t_stack **a, t_list **solution)
|
||||||
|
|||||||
Reference in New Issue
Block a user