void make_move(t_list **a, t_list **b, t_list **in, enum e_instr instr) { plug(in, new_node(instr)); if (instr == PA) push(a, pop(b)); if (instr == PB) push(b, pop(a)); if (instr == SA || instr == SS) swap(a); if (instr == SB || instr == SS) swap(b); if (instr == RA || instr == RR) rot_up(a); if (instr == RB || instr == RR) rot_up(b); if (instr == RRA || instr == RRR) rot_down(a); if (instr == RRB || instr == RRR) rot_down(b); }
int is_rotationally_sorted(t_list *list) { int count; t_list *l; count = lstlen(list); l = dupe_list(list); while (count--) { if (is_sorted(l)) return (1); rot_up(&l); } free_list(l); return (0); }
int key_hook(int keycode, t_rtv *rtv) { if (keycode == 53) { destroy_and_exit(rtv); } if (keycode == 126) { rot_up(rtv); } if (keycode == 125) { rot_down(rtv); } if (keycode == 124) { rot_right(rtv); } if (keycode == 123) { rot_left(rtv); } return (0); }