diff --git a/add_to_list.c b/add_to_list.c index 0a18586..cd67374 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/23 21:36:37 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/24 21:46:31 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,7 +23,7 @@ void print_bits(short line) { int mask; - mask = 1 << 27; + mask = 1 << 16; while (mask >>= 1) (line & mask) ? write(1, "1", 1) : write(1, "0", 1); write(1, "\n", 1); @@ -47,6 +47,7 @@ int fill_list(char line[], t_fillist *list) i++; if (line[i++] == '#') list->tetribit |= 1; + print_bits(list->tetribit); } // tmp = list->tetribit; // while (tmp) @@ -56,7 +57,7 @@ int fill_list(char line[], t_fillist *list) // list->tibirtet <<= 1; // tmp >>= 1; // } - print_bits(list->tetribit); +// print_bits(list->tetribit); return (0); } diff --git a/fillit.h b/fillit.h index 0fbd67c..d796a71 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/23 16:19:19 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/24 21:42:27 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,11 +38,12 @@ typedef struct s_fillist char *read_file(char *file); void print_error(char *s); -void parse_input(char *input); +void parse_input(char *input, t_fillist *list); int check_file_errors(char *file); int check_tetri_errors(char *tetri); int check_tetri_errors_proxy(char *tetri); int add_to_list(char *square, t_fillist **list); int fill_list(char *line, t_fillist *list); +void print_bits(short line); //TO DELETE BEFORE EVAL #endif diff --git a/get_smallest_square.c b/get_smallest_square.c index 4a4c8d2..80d89e8 100644 --- a/get_smallest_square.c +++ b/get_smallest_square.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */ -/* Updated: 2019/04/23 21:42:35 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/24 21:01:26 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/main.c b/main.c index 2448ba8..38b6ab4 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/23 21:39:42 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/24 21:42:45 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,8 @@ int main(int argc, char **argv) { - char *input; + char *input; + static t_fillist *list; if (argc == 2) { @@ -22,11 +23,15 @@ 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"); - parse_input(input); + parse_input(input, list); + while (list) + { + printf("%i\n", list->tetribit); + list = list->next; + } /* Backtracking for smallest square - Transform tetriminos with letters - Print result + Transform tetriminos with letters & Print result */ } else diff --git a/parse_input.c b/parse_input.c index 49ce03e..2ad7f65 100644 --- a/parse_input.c +++ b/parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/04/23 21:23:47 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/24 21:49:33 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,9 +16,8 @@ ** Function that parse a file and put each tetrimino in a linked list */ -void parse_input(char *input) +void parse_input(char *input, t_fillist *list) { - static t_fillist *list = NULL; char tetri[20]; int i; int j; @@ -34,21 +33,13 @@ void parse_input(char *input) if (check_tetri_errors(tetri)) print_error("Error: Tetrimino not valid."); add_to_list(tetri, &list); - printf("added to list !!\n"); while (input[i] && input[i] != '.' && input[i] != '#') i++; } -/*DEBUG PART - Print each tetribit*/ -// while (list != NULL) -// { -// printf("%i\n", list->tetribit); -// printf("\n"); -// list = list->next; -// } } /* -** DELETE BEFORE EVAL - NOT USED ANYMORE +** DELETE BEFORE EVAL // NOT USED ANYMORE ** Function that parse a file and put each tetrimino in a linked list */