diff --git a/add_to_list.c b/add_to_list.c index 371646a..4b69176 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -3,16 +3,19 @@ /* ::: :::::::: */ /* add_to_list.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hulamy +#+ +:+ +#+ */ +/* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/15 00:24:25 by hulamy ### ########.fr */ +/* Updated: 2019/04/15 14:38:43 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" #include +/* +** Function that ... +*/ void find_start_and_end(char **square, int *x1, int *x2, int *y1, int *y2) { @@ -36,6 +39,10 @@ void find_start_and_end(char **square, int *x1, int *x2, int *y1, int *y2) i--; } +/* +** Function that ... +*/ + char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) { char **result; @@ -63,6 +70,10 @@ char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) return (result); } +/* +** Function that ... +*/ + int add_to_list(char **square) { t_fillist *list; diff --git a/fillit.h b/fillit.h index e674e97..a7a5912 100644 --- a/fillit.h +++ b/fillit.h @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/15 00:26:08 by hulamy ### ########.fr */ +/* Updated: 2019/04/15 13:39:50 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,6 +39,10 @@ int check_tetri_errors(char *tetri); int check_tetri_errors2(char *tetri); int add_to_list(char **square); +/* +** STRUCTURE +*/ + typedef struct s_fillist { int id; diff --git a/handle_errors.c b/handle_errors.c index f553bb9..2f5a907 100644 --- a/handle_errors.c +++ b/handle_errors.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */ -/* Updated: 2019/04/15 00:13:18 by hulamy ### ########.fr */ +/* Updated: 2019/04/15 14:41:19 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,8 +42,9 @@ int check_file_errors(char *file) return (1); if (file[i] == '\n') line_nbr++; -// if (file[i] == '\n' && file[i+2] != '.' && file[i+2] != '#') -// return (1); + if (file[i] == '\n' && file[i+1] != '\0' && \ + file[i+2] != '.' && file[i+2] != '#') + return (1); i++; } if (line_nbr < 4 || line_nbr > 129) @@ -51,6 +52,12 @@ int check_file_errors(char *file) return (0); } +/* +** Function that check if tetrimino square contains: +** - 4 '#' +** - 12 '.' +*/ + int check_tetri_errors(char *tetri) { int i; @@ -73,6 +80,9 @@ int check_tetri_errors(char *tetri) return (0); } +/* +** Function that check if tetrimino parts are linked +*/ int check_tetri_errors2(char *tetri) { diff --git a/main.c b/main.c index b3bd85c..f05cc99 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/04/15 00:12:25 by hulamy ### ########.fr */ +/* Updated: 2019/04/15 14:41:44 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,10 +22,7 @@ int main(int argc, char **argv) print_error("Error: Could not read file.\n"); if (check_file_errors(input)) print_error("Error: Invalid file.\n"); - if (check_tetri_errors(input)) - print_error("Error: Tetrimino not valid.\n"); /* - Check if every tetrimino is valid Transform input to tetriminos Backtracking for smallest square Transform tetriminos with letters diff --git a/parse_input.c b/parse_input.c new file mode 100644 index 0000000..c6b1efb --- /dev/null +++ b/parse_input.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_input.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: vmanzoni +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ +/* Updated: 2019/04/15 15:10:01 by vmanzoni ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fillit.h" + +/* +** Function that parse a file and return each tetrimino +*/ + +void parse_input(char *input) +{ + char *tetri; + int i; + + i = 0; + while (input[i]) + { + tetri[i] = input[i]; + if (i != 0 && i%19 == 0) + { + + i+2; + } + } +} diff --git a/read_file.c b/read_file.c index 345e91f..a53e571 100644 --- a/read_file.c +++ b/read_file.c @@ -6,14 +6,14 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 23:01:31 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/15 14:48:36 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" /* -** Function that read and return a ptr to file +** Function that read and return a ptr to file content */ char *read_file(char *file) @@ -39,35 +39,3 @@ char *read_file(char *file) close(fd); return (result); } - -/* -** Function that parse a file and return each tetrimino -*/ - -int parse_input(char *input) -{ - char tetri; - int c; - int i; - int j; - - c = 0; - while (input[c]) - { - i = 0; - while (i < 4) - { - j = 0; - while (j < 4) - { - tetri[j] = input[c++]; - j++; - } - if (check_tetri_errors(tetri)) - print_error("Error: Tetrimino not valid.\n"); - c++; - i++; - } - c++; - } -}