need a bit a clean-up but a really nice sort =)
added optimised merge sort need to clean 'pb'-'pa' operation couple added visualizer on checker
This commit is contained in:
@@ -6,12 +6,38 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/23 13:35:15 by tmaze #+# #+# */
|
||||
/* Updated: 2019/03/09 14:57:41 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/03/09 22:44:29 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "push_swap.h"
|
||||
|
||||
#define VISU_SPEED 1000000
|
||||
|
||||
void debug(t_psdata *data, char *com)
|
||||
{
|
||||
t_stack *as;
|
||||
t_stack *bs;
|
||||
|
||||
as = data->a;
|
||||
bs = data->b;
|
||||
ft_printf(FT_CLEAR);
|
||||
ft_printf("============== %4s ==============\n", com);
|
||||
while (as || bs)
|
||||
{
|
||||
if (as && bs)
|
||||
ft_printf("%5d %4d|| %5d %4d\n", as->nb, as->ind, bs->nb, bs->ind);
|
||||
else if (!as && bs)
|
||||
ft_printf("%5c %4c|| %5d %4d\n", ' ', ' ', bs->nb, bs->ind);
|
||||
else if (as && !bs)
|
||||
ft_printf("%5d %4d|| %5c %c\n", as->nb, as->ind, ' ', ' ');
|
||||
as = (as) ? as->next : as;
|
||||
bs = (bs) ? bs->next : bs;
|
||||
}
|
||||
ft_printf("==================================\n");
|
||||
usleep(VISU_SPEED);
|
||||
}
|
||||
|
||||
void exec_actions(t_psdata *data)
|
||||
{
|
||||
char *buff;
|
||||
@@ -37,6 +63,7 @@ void exec_actions(t_psdata *data)
|
||||
ps_rerot(data, buff[2]);
|
||||
else if (buff[2] == 'r')
|
||||
ps_rrerot(data);
|
||||
debug(data, buff);
|
||||
nop = nop->next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user