some sort of refactoring :)

This commit is contained in:
Gregory Tertyshny 2016-12-22 21:12:16 +02:00
parent 46387d1666
commit fb65872848
5 changed files with 23 additions and 25 deletions

View file

@ -6,7 +6,7 @@
# By: gtertysh <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/12/14 16:54:48 by gtertysh #+# #+# #
# Updated: 2016/12/20 20:37:58 by gtertysh ### ########.fr #
# Updated: 2016/12/22 18:18:36 by gtertysh ### ########.fr #
# #
# **************************************************************************** #
@ -45,7 +45,7 @@ LIBFLAGS = -lft -L $(LIBFOLDER)
LIBFOLDER = ./libft/
FLAGS = -Werror -Wextra -Wall
FLAGS = -Werror -Wextra -Wall -O2
CC = clang

View file

@ -97,9 +97,9 @@ void add_row(int *col_numbers, t_node **cols_arr, t_coord coord, int
void search(t_node* root, t_node **solution, int k, int amount);
void cover(t_node *to_cover);
int cover(t_node *to_cover);
void uncover(t_node *to_uncover);
int uncover(t_node *to_uncover);
int *get_types(char **ttr);
@ -109,4 +109,6 @@ unsigned int ft_sqrt_ceil(unsigned int num);
void fill_map(char *map, int size, t_node *ttr, int letter);
void init(char **argv);
#endif

View file

@ -146,7 +146,7 @@ void add_rows(int *types, int amount, int size, t_node **cols_arr)
}
}
void cover(t_node *to_cover)
int cover(t_node *to_cover)
{
static t_node *step_vert;
static t_node *step_horiz;
@ -164,9 +164,10 @@ void cover(t_node *to_cover)
}
step_vert = step_vert->down;
}
return (1);
}
void uncover(t_node *to_uncover)
int uncover(t_node *to_uncover)
{
static t_node *step_vert;
static t_node *step_horiz;
@ -185,6 +186,7 @@ void uncover(t_node *to_uncover)
}
to_uncover->left->right = to_uncover;
to_uncover->right->left = to_uncover;
return (1);
}
void fill_map(char *map, int size, t_node *ttr, int letter)
@ -244,18 +246,12 @@ void search(t_node* root,t_node **solution, int k, int amount)
{
solution[k] = row;
j = row->right;
while (j != row)
{
cover(j->column);
while (j != row && cover(j->column))
j = j->right;
}
search(root, solution, k + 1, amount);
j = row->left;
while (j != row)
{
uncover(j->column);
while (j != row && uncover(j->column))
j = j->left;
}
row = row->down;
}
uncover(current_col);

View file

@ -13,7 +13,9 @@
#include "fillit.h"
/*
** bad global variable
** definition of global variable
** that contains all possible tetrominoes
** inside 4x4 square with initial coordinates at [0][0]
*/
t_ttrmn g_templates[19] =
@ -54,16 +56,14 @@ int main(int argc, char **argv)
ans = NULL;
i = 0;
if (argc != 2)
{
ft_putstr("error\n");
return (1);
}
if (!(string = read_file(argv[1])))
{
ft_putstr("error\n");
return (1);
} //printf("string:\n\n\n%s\n", string);
else
init(argv[1]);
string = read_file(argv[1]);
//printf("string:\n\n\n%s\n", string);
table = to_table(&string);
//printf("print_table:\n\n\n");

Binary file not shown.