From 6be9cc0cbc8e86a8d88aea247fbd5b30d9588a2f Mon Sep 17 00:00:00 2001 From: Gregory Tertyshny Date: Thu, 15 Dec 2016 19:16:26 +0200 Subject: [PATCH 1/3] new check for raw string (doesn't work) --- Makefile | 3 +- inc/fillit.h | 6 +- src/check_raw_string.c | 34 ++++++++++ src/main.c | 149 ++++++++++------------------------------- src/read_file.c | 2 +- src/test!_check.c | 6 +- 6 files changed, 78 insertions(+), 122 deletions(-) create mode 100644 src/check_raw_string.c diff --git a/Makefile b/Makefile index 54405ef..aa615d1 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ SRC_FILES = main.c \ to_letters.c \ test!_check.c \ test!_print_one_string.c \ - test!_print_table.c + test!_print_table.c \ + check_raw_string.c OBJ_FILES = $(SRC_FILES:.c=.o) diff --git a/inc/fillit.h b/inc/fillit.h index fc43bd4..1c1a18b 100644 --- a/inc/fillit.h +++ b/inc/fillit.h @@ -36,7 +36,6 @@ typedef struct s_map unsigned int figure_amount; } t_map; -// obsolete, rewrite for unit16 typedef struct s_tetrominoes_templates { char figure[17]; @@ -64,10 +63,13 @@ void move_up_left(char **table); void print_one_string(char **glued); // compare 19 templates with each tetromino in *ttr table -void test_check(char **ttr, t_tetrominoes_templates *tamplates); +void test_check(char **ttr, char **tamplates); // change hashes ('#') with letters // obsolete, rewrite for structs array void to_letters(char **ttr); +// проверка считаной строки +int check_raw_string(char *raw_string); + #endif diff --git a/src/check_raw_string.c b/src/check_raw_string.c new file mode 100644 index 0000000..9376456 --- /dev/null +++ b/src/check_raw_string.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* check_raw_string.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: gtertysh +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/12/15 18:32:54 by gtertysh #+# #+# */ +/* Updated: 2016/12/15 18:32:58 by gtertysh ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int check_raw_string(char *raw_string) +{ + int n_count; + + n_count = 0; + if (*raw_string == 0 || *raw_string == '\n') + return (1); + while(*raw_string) + { + if (*raw_string == '\n') + n_count++; + if ((n_count + 1) % 4 == 0) + if (*(raw_string + 1) != '\0') + if (*(raw_string + 1) != '\n' && !(*(raw_string + 2) == '.' || *(raw_string + 2) == '#')) + return (1); + raw_string++; + + } + if (n_count < 3) + return (1); + return (0); +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index e9610f4..de91053 100644 --- a/src/main.c +++ b/src/main.c @@ -12,103 +12,26 @@ #include "fillit.h" -// bad global variable -t_tetrominoes_templates templates[19] = -{ - { "#..." - "#..." - "#..." - "#..." }, - - { "####" - "...." - "...." - "...." }, - - { "#..." - "#..." - "##.." - "...." }, - - { "..#." - "###." - "...." - "...." }, - - { "##.." - ".#.." - ".#.." - "...." }, - - { "###." - "#..." - "...." - "...." }, - - { ".#.." - ".#.." - "##.." - "...." }, - - { "###." - "..#." - "...." - "...." }, - - { "##.." - "#..." - "#..." - "...." }, - - { "#..." - "###." - "...." - "...." }, - - { "###." - ".#.." - "...." - "...." }, - - { "#..." - "##.." - "#..." - "...." }, - - { ".#.." - "###." - "...." - "...." }, - - { ".#.." - "##.." - ".#.." - "...." }, - - { "##.." - "##.." - "...." - "...." }, - - { "##.." - ".##." - "...." - "...." }, - - { ".#.." - "##.." - "#..." - "...." }, - - { ".##." - "##.." - "...." - "...." }, - - { "#..." - "##.." - ".#.." - "...." } +char *str_templates[19] = +{ "#...#...#...#...", + "####............", + "#...#...##......", + "..#.###.........", + "##...#...#......", + "###.#...........", + ".#...#..##......", + "###...#.........", + "##..#...#.......", + "#...###.........", + "###..#..........", + "#...##..#.......", + ".#..###.........", + ".#..##...#......", + "##..##..........", + "##...##.........", + ".#..##..#.......", + ".##.##..........", + "#...##...#......" }; int main(int argc, char **argv) @@ -124,31 +47,27 @@ int main(int argc, char **argv) ft_putstr("error\n"); return (1); } - string = read_file(argv[1]); if (!(string = read_file(argv[1]))) { ft_putstr("error\n"); return (1); } - printf("string:\n\n\n%s\n", string); - + if (check_raw_string(string)) + { + ft_putstr("error\n"); + return (1); + } table = to_table(&string); - printf("print_table:\n\n\n"); - print_table(table); - + // if (check_string_table(table)) + // { + // ft_putstr("error\n"); + // return (1); + // } ttr = glue_figure(table); - printf("glued figures:\n\n\n"); - print_one_string(ttr); - move_up_left(ttr); - printf("move to up left:\n\n\n"); - print_one_string(ttr); - - printf("test check:\n\n"); - test_check(ttr, templates); - - to_letters(ttr); - printf("to latters:\n\n"); - print_one_string(ttr); + //print_one_string(ttr); + test_check(ttr, str_templates); + //to_letters(ttr); + // print_one_string(ttr); return (0); } diff --git a/src/read_file.c b/src/read_file.c index 6dfb512..62b1ebf 100644 --- a/src/read_file.c +++ b/src/read_file.c @@ -32,7 +32,7 @@ char *read_file(char *path) string = ft_memalloc(sizeof(char) * BUF_S); while ((readed = read(fd, buf, BUF_S))) { - buf[BUF_S] = '\0'; + buf[readed] = '\0'; old_size = ft_strlen(string); string = ft_realloc(string, old_size + readed, old_size); ft_strcat(string, buf); diff --git a/src/test!_check.c b/src/test!_check.c index 373200e..999272d 100644 --- a/src/test!_check.c +++ b/src/test!_check.c @@ -14,7 +14,7 @@ // Test func. Compare figures from file // with templates -void test_check(char **ttr, t_tetrominoes_templates *tamplates) +void test_check(char **ttr, char **tamplates) { int i; int j; @@ -28,8 +28,8 @@ void test_check(char **ttr, t_tetrominoes_templates *tamplates) printf("\n\ninput:\n"); printf("%s\n", ttr[i]); printf("\n\ntemplate:\n"); - printf("%s\n", tamplates[j].figure); - if ((ft_memcmp(ttr[i], tamplates[j].figure, 17) == 0)) + printf("%s\n", tamplates[j]); + if ((ft_memcmp(ttr[i], tamplates[j], 17) == 0)) printf(" match!\n"); j++; } From 32d05000482cb476d85597af56c520986b489887 Mon Sep 17 00:00:00 2001 From: Gregory Date: Tue, 20 Dec 2016 05:47:48 +0200 Subject: [PATCH 2/3] 2 new functions: to_strct_array and build matrix --- .gitignore | 3 + Makefile | 3 +- inc/fillit.h | 37 ++++------ src/build_matrix.c | 106 +++++++++++++++++++++++++++ src/glue_figure.c | 2 +- src/main.c | 170 ++++++++++++++++++++----------------------- src/test!_check.c | 6 +- src/to_strct_array.c | 33 +++++++++ 8 files changed, 241 insertions(+), 119 deletions(-) create mode 100644 src/build_matrix.c create mode 100644 src/to_strct_array.c diff --git a/.gitignore b/.gitignore index e318427..b8cecc6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ # Vim temp *.swp + +# Sublime files +*.sublime* diff --git a/Makefile b/Makefile index 54405ef..c6da964 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,13 @@ SRCDIR = ./src/ OBJDIR = ./obj/ SRC_FILES = main.c \ - fillit.c \ glue_figure.c \ move_up_left.c \ read_file.c \ string_to_table.c \ + to_strct_array.c \ to_letters.c \ + build_matrix.c \ test!_check.c \ test!_print_one_string.c \ test!_print_table.c diff --git a/inc/fillit.h b/inc/fillit.h index fc43bd4..33dd4f4 100644 --- a/inc/fillit.h +++ b/inc/fillit.h @@ -17,33 +17,18 @@ #include #include #include +#include #include // warning! # define BUF_S 8192 +# define HOW_MUCH 10000 -typedef struct s_tetrominoes +typedef struct s_ttrmn { - uint16_t line[16]; - int offset_y; - int height; -} t_tetrominoes; - -typedef struct s_map -{ - uint16_t line[16]; - unsigned int size; - t_tetrominoes *figure[26]; - unsigned int figure_amount; -} t_map; - -// obsolete, rewrite for unit16 -typedef struct s_tetrominoes_templates -{ - char figure[17]; -} t_tetrominoes_templates; - -void convert_tetramino(char *s, t_map *map, int index); -void map_initialization(char **tetramino_table, t_map *map); + char t[17]; + int x; + int y; +} t_ttrmn; // reads from file char *read_file(char *path); @@ -64,10 +49,16 @@ void move_up_left(char **table); void print_one_string(char **glued); // compare 19 templates with each tetromino in *ttr table -void test_check(char **ttr, t_tetrominoes_templates *tamplates); +void test_check(char **ttr, t_ttrmn *tamplates); // change hashes ('#') with letters // obsolete, rewrite for structs array void to_letters(char **ttr); +// create array of ttr structures +t_ttrmn **to_strct_array(char **ttr, t_ttrmn *templates); + +// build matrix for algorythm X +int **build_matrix(t_ttrmn **ttr); + #endif diff --git a/src/build_matrix.c b/src/build_matrix.c new file mode 100644 index 0000000..1942d4c --- /dev/null +++ b/src/build_matrix.c @@ -0,0 +1,106 @@ +#include "fillit.h" + +unsigned int ft_sqrt_ceil(unsigned int num) +{ + unsigned int i; + + i = 1; + while (i * i < num) + i++; + return (i); +} + +void put_figure(char **char_matrix, t_ttrmn t, int y, int x) +{ + int i; + int j; + int t_x; + int runner; + + t_x = x; + i = 0; + runner = 0; + while (i < t.y) + { + x = t_x; + j = 0; + while (j < t.x) + { + char_matrix[y][x] = t.t[runner]; + j++; + x++; + runner++; + } + } +} + +void print_char_matrix(char **matrix, int size) +{ + int y; + + y = 0; + while (y < size) + { + printf("%s\n", matrix[y]); + y++; + } +} + +int **build_matrix(t_ttrmn **ttr) +{ + int **matrix; + char **char_matrix; + int i; + int j; + int amount; + int size; + int k; + int curr_line; + + amount = 0; + i = 0; + matrix = malloc(sizeof(int*) * HOW_MUCH); + while (i < HOW_MUCH) + { + j = 0; + matrix[i] = malloc(sizeof(int) * HOW_MUCH); + while (j < HOW_MUCH) + matrix[i][j++] = -1; + i++; + } + while(ttr[amount]) + amount++; + size = ft_sqrt_ceil(amount * 4); + if (size < 4) + size = 4; + char_matrix = malloc(sizeof(char *) * size + 1); + i = 0; + while (i < size) + { + char_matrix[i] = malloc(sizeof(char) * size + 1); + char_matrix[i][size] = 0; + i++; + } + char_matrix[size] = 0; + i = 0; + curr_line = 0; + while (i < amount) + { + k = 0; + while (k < size - ttr[i]->y) + { + j = 0; + while (j < size - ttr[i]->x) + { + put_figure(char_matrix, *ttr[i], k, j); + //print_char_matrix(char_matrix, size); + //count_cover(matrix, char_matrix, curr_line++); + //clear_char_matrix(&char_matrix, size); + j++; + } + k++; + } + i++; + } + return (matrix); +} \ No newline at end of file diff --git a/src/glue_figure.c b/src/glue_figure.c index f3719ad..099a012 100644 --- a/src/glue_figure.c +++ b/src/glue_figure.c @@ -14,7 +14,7 @@ // This function creates string table in which one line represent one figure // by "glueing" evry 4 strings from table -char **glue_figure(char **table) +char **glue_figure(char **table) { int i; int j; diff --git a/src/main.c b/src/main.c index e9610f4..885e851 100644 --- a/src/main.c +++ b/src/main.c @@ -13,102 +13,83 @@ #include "fillit.h" // bad global variable -t_tetrominoes_templates templates[19] = +t_ttrmn templates[19] = { - { "#..." - "#..." - "#..." - "#..." }, + { .t = "#...#...#...#...", + .x = 1, + .y = 4}, - { "####" - "...." - "...." - "...." }, + { .t = "####............", + .x = 4, + .y = 1}, - { "#..." - "#..." - "##.." - "...." }, + { .t = "#...#...##......", + .x = 2, + .y = 3}, - { "..#." - "###." - "...." - "...." }, + { .t = "..#.###.........", + .x = 3, + .y = 2}, - { "##.." - ".#.." - ".#.." - "...." }, + { .t = "##...#...#......", + .x = 2, + .y = 3}, - { "###." - "#..." - "...." - "...." }, + { .t = "###.#...........", + .x = 3, + .y = 2}, - { ".#.." - ".#.." - "##.." - "...." }, + { .t = ".#...#..##......", + .x = 2, + .y = 3}, - { "###." - "..#." - "...." - "...." }, + { .t = "###...#.........", + .x = 3, + .y = 2}, - { "##.." - "#..." - "#..." - "...." }, + { .t = "##..#...#.......", + .x = 2, + .y = 3}, - { "#..." - "###." - "...." - "...." }, + { .t = "#...###.........", + .x = 3, + .y = 2}, - { "###." - ".#.." - "...." - "...." }, + { .t = "###..#..........", + .x = 3, + .y = 2}, - { "#..." - "##.." - "#..." - "...." }, + { .t = "#...##..#.......", + .x = 2, + .y = 3}, - { ".#.." - "###." - "...." - "...." }, + { .t = ".#..###.........", + .x = 3, + .y = 2}, - { ".#.." - "##.." - ".#.." - "...." }, + { .t = ".#..##...#......", + .x = 2, + .y = 3}, - { "##.." - "##.." - "...." - "...." }, + { .t = "##..##..........", + .x = 2, + .y = 2}, - { "##.." - ".##." - "...." - "...." }, + { .t = "##...##.........", + .x = 3, + .y = 2}, - { ".#.." - "##.." - "#..." - "...." }, + { .t = ".#..##..#.......", + .x = 2, + .y = 3}, - { ".##." - "##.." - "...." - "...." }, + { .t = ".##.##..........", + .x = 3, + .y = 2}, - { "#..." - "##.." - ".#.." - "...." } + { .t = "#...##...#......", + .x = 2, + .y = 3} }; int main(int argc, char **argv) @@ -117,6 +98,8 @@ int main(int argc, char **argv) char **table; char **ttr; int i; + t_ttrmn **strct_ttr; + int **matrix; i = 0; if (argc != 2) @@ -124,31 +107,36 @@ int main(int argc, char **argv) ft_putstr("error\n"); return (1); } - string = read_file(argv[1]); if (!(string = read_file(argv[1]))) { ft_putstr("error\n"); return (1); } - printf("string:\n\n\n%s\n", string); + //printf("string:\n\n\n%s\n", string); table = to_table(&string); - printf("print_table:\n\n\n"); - print_table(table); + //printf("print_table:\n\n\n"); + //print_table(table); ttr = glue_figure(table); - printf("glued figures:\n\n\n"); - print_one_string(ttr); - + //printf("glued figures:\n\n\n"); + //print_one_string(ttr); move_up_left(ttr); - printf("move to up left:\n\n\n"); - print_one_string(ttr); + //printf("move to up left:\n\n\n"); + //print_one_string(ttr); - printf("test check:\n\n"); - test_check(ttr, templates); + //printf("test check:\n\n"); + //test_check(ttr, templates); - to_letters(ttr); - printf("to latters:\n\n"); - print_one_string(ttr); + strct_ttr = to_strct_array(ttr, templates); + + + matrix = build_matrix(strct_ttr); + //printf("%s\n %d, %d", strct_ttr[0]->t, strct_ttr[0]->x, strct_ttr[0]->y); + //to_letters(ttr); + //printf("to latters:\n\n"); + //print_one_string(ttr); + + return (0); } diff --git a/src/test!_check.c b/src/test!_check.c index 373200e..ec40143 100644 --- a/src/test!_check.c +++ b/src/test!_check.c @@ -14,7 +14,7 @@ // Test func. Compare figures from file // with templates -void test_check(char **ttr, t_tetrominoes_templates *tamplates) +void test_check(char **ttr, t_ttrmn *tamplates) { int i; int j; @@ -28,8 +28,8 @@ void test_check(char **ttr, t_tetrominoes_templates *tamplates) printf("\n\ninput:\n"); printf("%s\n", ttr[i]); printf("\n\ntemplate:\n"); - printf("%s\n", tamplates[j].figure); - if ((ft_memcmp(ttr[i], tamplates[j].figure, 17) == 0)) + printf("%s\n", tamplates[j].t); + if ((ft_memcmp(ttr[i], tamplates[j].t, 17) == 0)) printf(" match!\n"); j++; } diff --git a/src/to_strct_array.c b/src/to_strct_array.c new file mode 100644 index 0000000..11cebdb --- /dev/null +++ b/src/to_strct_array.c @@ -0,0 +1,33 @@ + +#include "fillit.h" + +t_ttrmn **to_strct_array(char **ttr, t_ttrmn *templates) +{ + t_ttrmn **ret; + int amount; + int i; + int j; + int k; + + amount = 0; + i = 0; + k = 0; + while (ttr[amount]) + amount++; + ret = malloc(sizeof(ret) * (amount + 1)); + while (k < amount) + ret[k++] = malloc(sizeof(t_ttrmn)); + ret[k] = 0; + while (i < amount) + { + j = 0; + while(ft_strcmp(templates[j].t, ttr[i]) != 0) + j++; + //printf("%d\n", j); + ft_strcpy(ret[i]->t, ttr[i]); + ret[i]->x = templates[j].x; + ret[i]->y = templates[j].y; + i++; + } + return (ret); +} \ No newline at end of file From 9f78ae581004c3597836ec531c9f8bdf2102f4a2 Mon Sep 17 00:00:00 2001 From: Gregory Tertyshny Date: Tue, 20 Dec 2016 19:40:21 +0200 Subject: [PATCH 3/3] dancing links method --- Makefile | 3 +- inc/fillit.h | 45 +++++++++++++++++++++----- src/dancing_links.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 19 ++++++----- 4 files changed, 126 insertions(+), 19 deletions(-) create mode 100644 src/dancing_links.c diff --git a/Makefile b/Makefile index 894ec89..ea31f51 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: gtertysh +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/12/14 16:54:48 by gtertysh #+# #+# # -# Updated: 2016/12/14 18:41:33 by gtertysh ### ########.fr # +# Updated: 2016/12/20 19:05:59 by gtertysh ### ########.fr # # # # **************************************************************************** # @@ -24,6 +24,7 @@ SRC_FILES = main.c \ to_strct_array.c \ to_letters.c \ build_matrix.c \ + dancing_links.c \ test!_check.c \ test!_print_one_string.c \ test!_print_table.c \ diff --git a/inc/fillit.h b/inc/fillit.h index d564862..91297f0 100644 --- a/inc/fillit.h +++ b/inc/fillit.h @@ -6,7 +6,7 @@ /* By: gtertysh +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/14 16:42:06 by gtertysh #+# #+# */ -/* Updated: 2016/12/20 18:59:06 by gtertysh ### ########.fr */ +/* Updated: 2016/12/20 19:18:00 by gtertysh ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,14 +23,39 @@ # define BUF_S 8192 # define HOW_MUCH 10000 +typedef struct s_coord +{ + int x; + int y; +} t_coord; + typedef struct s_ttrmn { - char t[17]; - int x; - int y; - int coord[4]; + char t[17]; + int x; + int y; + t_coord c[4]; } t_ttrmn; +typedef struct s_col +{ + struct s_col *left; + struct s_col *right; + void *up; + void *down; +} t_col; + +typedef struct s_node +{ + struct s_node *left; + struct s_node *right; + struct s_node *up; + struct s_node *down; + int row; + t_col *column; +} t_node; + + // reads from file char *read_file(char *path); @@ -57,9 +82,13 @@ void test_check(char **ttr, t_ttrmn *tamplates); void to_letters(char **ttr); // create array of ttr structures -t_ttrmn **to_strct_array(char **ttr, t_ttrmn *templates); +int *to_strct_array(char **ttr, t_ttrmn *templates); + +t_col *add_column(t_col *root); +t_node *add_node(t_col *col, int row); +void cover(t_col *to_cover); +void uncover(t_col *to_uncover); + -// build matrix for algorythm X -int **build_matrix(t_ttrmn **ttr); #endif diff --git a/src/dancing_links.c b/src/dancing_links.c new file mode 100644 index 0000000..6d333e7 --- /dev/null +++ b/src/dancing_links.c @@ -0,0 +1,78 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* dancing_links.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: gtertysh +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/12/20 19:21:42 by gtertysh #+# #+# */ +/* Updated: 2016/12/20 19:22:04 by gtertysh ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fillit.h" + +// t_col *add_column(t_col *root) +// { +// t_col *new_col; + +// new_col = (t_col*)malloc(sizeof(t_col)); +// new_col->down = (void*)new_col; +// new_col->up = (void*)new_col; +// new_col->left = root->left; +// new_col->right = root; +// return (new_col); +// } + +// t_node *add_node(t_col *col, int row) +// { +// t_node *new_node; + +// new_node = (t_node*)malloc(sizeof(t_node)); +// new_node->row = row; +// new_node->up = (t_node*)col->up; +// new_node->down = (t_node*)col; +// col->up->down = new_node; +// col->up = new_node; +// return (new_node); +// } + +// void cover(t_col *to_cover) +// { +// void *step_vert; +// t_node *step_horiz; + +// to_cover->left->right = to_cover->right; +// to_cover->right->left = to_cover->left; +// step_vert = to_cover->down; +// while (step_vert != (void*)to_cover) +// { +// step_horiz = (t_node*)step_vert->right; +// while (step_horiz != (t_node*)step_vert) { +// step_horiz->down->up = step_horiz->up; +// step_horiz->up->down = step_horiz->down; +// step_horiz = step_horiz->right; +// } +// step_vert = (t_node*)step_vert->down; +// } +// } + +// void uncover(t_col *to_uncover) +// { +// void *step_vert; +// t_node *step_horiz; + +// step_vert = to_uncover->up; +// while (step_vert != (void*)to_uncover) +// { +// step_horiz = (t_node*)step_vert->left; +// while (step_horiz != (t_node*)step_vert) +// { +// step_horiz->down->up = step_horiz; +// step_horiz->up->down = step_horiz; +// step_horiz = step_horiz->left; +// } +// step_vert = (t_node*)step_vert->up; +// } +// } + diff --git a/src/main.c b/src/main.c index a6d65ff..2db37a6 100644 --- a/src/main.c +++ b/src/main.c @@ -6,18 +6,19 @@ /* By: gtertysh +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:07:25 by gtertysh #+# #+# */ -/* Updated: 2016/12/20 18:59:59 by gtertysh ### ########.fr */ +/* Updated: 2016/12/20 19:21:09 by gtertysh ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" // bad global variable -t_ttrmn templates[19] = +t_ttrmn g_templates[19] = { - { .t = "#...#...#...#...", - .x = 1, - .y = 4}, + { + "#...#...#...#...", 1, 4, .c[0] = {0, 0}, .c[1] = {1, 0}, + .c[2] = {2, 0}, .c[3] = {3, 0} + }, { .t = "####............", .x = 4, @@ -98,9 +99,8 @@ int main(int argc, char **argv) char **table; char **ttr; int i; - t_ttrmn **strct_ttr; - int **matrix; - + int *types; + i = 0; if (argc != 2) { @@ -128,10 +128,9 @@ int main(int argc, char **argv) //printf("test check:\n\n"); //test_check(ttr, templates); - strct_ttr = to_strct_array(ttr, templates); + types = to_strct_array(ttr, g_templates); - matrix = build_matrix(strct_ttr); //printf("%s\n %d, %d", strct_ttr[0]->t, strct_ttr[0]->x, strct_ttr[0]->y); //to_letters(ttr); //printf("to latters:\n\n");