bug resolved + few edits

This commit is contained in:
Manzovince
2019-04-24 21:50:51 +02:00
parent 39a59058ba
commit 2bac429596
5 changed files with 21 additions and 23 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

15
main.c
View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
*/