ajout de test_big_tetri.c et merge conflict
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/04/24 13:45:53 by hulamy ### ########.fr */
|
/* Updated: 2019/04/25 13:06:01 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -18,15 +18,15 @@
|
|||||||
** Function that prints a 16 bites short
|
** Function that prints a 16 bites short
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//void print_bits(short line)
|
void print_bits(short line)
|
||||||
//{
|
{
|
||||||
// int mask;
|
int mask;
|
||||||
//
|
|
||||||
// mask = 1 << 16;
|
mask = 1 << 16;
|
||||||
// while (mask >>= 1)
|
while (mask >>= 1)
|
||||||
// (line & mask) ? write(1, "1", 1) : write(1, "0", 1);
|
(line & mask) ? write(1, "1", 1) : write(1, "0", 1);
|
||||||
// write(1, "\n", 1);
|
write(1, "\n", 1);
|
||||||
//}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Function that transforme a tetrminos char* into a short of 16 bites
|
** Function that transforme a tetrminos char* into a short of 16 bites
|
||||||
@@ -46,17 +46,18 @@ void fill_list(char line[], t_fillist *list)
|
|||||||
i++;
|
i++;
|
||||||
if (line[i++] == '#')
|
if (line[i++] == '#')
|
||||||
list->tetribit |= 1;
|
list->tetribit |= 1;
|
||||||
|
print_bits(list->tetribit);
|
||||||
}
|
}
|
||||||
while (!(list->tetribit & (1 << 15)))
|
// tmp = list->tetribit;
|
||||||
list->tetribit <<= 1;
|
// while (tmp)
|
||||||
tmp = list->tetribit;
|
// {
|
||||||
while (tmp)
|
// if (tmp & 1)
|
||||||
{
|
// list->tibirtet |= 1;
|
||||||
list->tibirtet <<= 1;
|
// list->tibirtet <<= 1;
|
||||||
if (tmp & 1)
|
// tmp >>= 1;
|
||||||
list->tibirtet |= 1;
|
// }
|
||||||
tmp >>= 1;
|
// print_bits(list->tetribit);
|
||||||
}
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
6
fillit.h
6
fillit.h
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/04/24 13:46:32 by hulamy ### ########.fr */
|
/* Updated: 2019/04/25 13:04:13 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -39,10 +39,12 @@ typedef struct s_fillist
|
|||||||
|
|
||||||
char *read_file(char *file);
|
char *read_file(char *file);
|
||||||
void print_error(char *s);
|
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_file_errors(char *file);
|
||||||
int check_tetri_errors(char *tetri);
|
int check_tetri_errors(char *tetri);
|
||||||
int check_tetri_errors_proxy(char *tetri);
|
int check_tetri_errors_proxy(char *tetri);
|
||||||
int add_to_list(char *square, t_fillist **list);
|
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
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/12 22:29:45 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
15
main.c
15
main.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/02/12 13:20:48 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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *input;
|
char *input;
|
||||||
|
static t_fillist *list;
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
@@ -22,11 +23,15 @@ int main(int argc, char **argv)
|
|||||||
print_error("Error: Could not read file.\n");
|
print_error("Error: Could not read file.\n");
|
||||||
if (check_file_errors(input))
|
if (check_file_errors(input))
|
||||||
print_error("Error: Invalid file.\n");
|
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
|
Backtracking for smallest square
|
||||||
Transform tetriminos with letters
|
Transform tetriminos with letters & Print result
|
||||||
Print result
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/04/24 13:48:21 by hulamy ### ########.fr */
|
/* Updated: 2019/04/25 13:03:52 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -33,9 +33,8 @@
|
|||||||
** Function that parse a file and put each tetrimino in a linked list
|
** 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];
|
char tetri[20];
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@@ -51,24 +50,13 @@ void parse_input(char *input)
|
|||||||
if (check_tetri_errors(tetri))
|
if (check_tetri_errors(tetri))
|
||||||
print_error("Error: Tetrimino not valid.");
|
print_error("Error: Tetrimino not valid.");
|
||||||
add_to_list(tetri, &list);
|
add_to_list(tetri, &list);
|
||||||
// printf("added to list !!\n");
|
|
||||||
while (input[i] && input[i] != '.' && input[i] != '#')
|
while (input[i] && input[i] != '.' && input[i] != '#')
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* DEBUG PART - Print each tetribit*/
|
|
||||||
// while (list != NULL)
|
|
||||||
// {
|
|
||||||
// printf("%i\n", list->tetribit);
|
|
||||||
// print_short(list->tetribit);
|
|
||||||
// printf("\n");
|
|
||||||
// print_short(list->tibirtet);
|
|
||||||
// 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
|
** Function that parse a file and put each tetrimino in a linked list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user