rangement des fichiers tests et makefile
This commit is contained in:
58
Makefile
58
Makefile
@@ -6,49 +6,43 @@
|
|||||||
# By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ #
|
# By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2019/03/01 13:24:35 by vmanzoni #+# #+# #
|
# Created: 2019/03/01 13:24:35 by vmanzoni #+# #+# #
|
||||||
# Updated: 2019/04/24 13:49:48 by hulamy ### ########.fr #
|
# Updated: 2019/04/24 15:44:55 by hulamy ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = fillit
|
# - - - - - - - - - - - - - - - #
|
||||||
|
# VARIABLES #
|
||||||
|
# - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
OBJ_DIR = ./objs
|
NAME = fillit
|
||||||
HEADER = fillit.h
|
CC = gcc
|
||||||
|
|
||||||
SRCS = main.c \
|
CFLAGS = -I.
|
||||||
read_file.c \
|
CFLAGS += -Wall -Wextra -Werror
|
||||||
handle_errors.c \
|
|
||||||
parse_input.c \
|
LDFLAGS = -L./libft/
|
||||||
add_to_list.c \
|
LDLIBS = -lft
|
||||||
# get_smallest_square.c \
|
|
||||||
print_fillit.c
|
SRCS = $(shell find . -depth 1 -type f -not -name '.*' -not -name 'test*' -name '*.c')
|
||||||
|
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
# - - - - - - - - - - - - - - - #
|
||||||
LIB = libft/
|
# RULES #
|
||||||
|
# - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
CC = gcc
|
all: $(NAME)
|
||||||
CFLAGS = -Wall -Werror -Wextra
|
|
||||||
|
|
||||||
RM = rm -rf
|
$(NAME): $(SRCS)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(SRCS) -o $(NAME)
|
||||||
|
|
||||||
all: $(NAME)
|
debug:
|
||||||
|
$(CC) -g $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(SRCS) -o $(NAME)
|
||||||
|
|
||||||
$(NAME):
|
lib:
|
||||||
make -C $(LIB)
|
make -C ./libft/
|
||||||
$(CC) $(CFLAGS) -I$(HEADER) -c $(SRCS)
|
|
||||||
$(CC) -o $(NAME) $(OBJS) -L $(LIB) -lft
|
|
||||||
mkdir $(OBJ_DIR)
|
|
||||||
mv $(OBJS) $(OBJ_DIR)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make -C libft/ clean
|
/bin/rm -rf $(NAME)
|
||||||
$(RM) $(OBJ_DIR)
|
/bin/rm -rf $(NAME).dSYM
|
||||||
|
|
||||||
fclean: clean
|
re: clean all
|
||||||
make -C libft/ fclean
|
|
||||||
$(RM) $(NAME)
|
|
||||||
|
|
||||||
re: fclean all
|
|
||||||
|
|
||||||
.PHONY: all clean fclean re
|
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -1,20 +0,0 @@
|
|||||||
# Fillit
|
|
||||||
|
|
||||||
**hulamy** and **vmanzoni**
|
|
||||||
|
|
||||||
## To do
|
|
||||||
|
|
||||||
- [x] Check if we have a file
|
|
||||||
- [x] Read file
|
|
||||||
- [x] Check if there are errors in file
|
|
||||||
- At least 1 tetrimino or less than 26
|
|
||||||
- [x] Check if every tetrimino is valid
|
|
||||||
- 4 char * 4 lines
|
|
||||||
- 4 blocks in 1 tetrimino
|
|
||||||
- No solo block
|
|
||||||
- [x] Transform file into tetriminos
|
|
||||||
- [ ] Backtracking for smallest square
|
|
||||||
- [ ] Transform tetriminos to letters
|
|
||||||
- [ ] Print result
|
|
||||||
|
|
||||||
- [ ] Optimisation
|
|
||||||
103
parse_input.c
103
parse_input.c
@@ -6,28 +6,63 @@
|
|||||||
/* 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/24 15:12:32 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "fillit.h"
|
#include "fillit.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** DELETE BEFORE EVAL
|
** Function that transforme a tetrminos char* into a short of 16 bites
|
||||||
** Function that print a short in bites
|
** and then fills it and its reversed into the list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//void print_short(short octet)
|
void fill_list(char line[], t_fillist *list)
|
||||||
//{
|
{
|
||||||
// unsigned int i;
|
unsigned short tmp;
|
||||||
//
|
int i;
|
||||||
// i = 1 << 15;
|
|
||||||
// while (i)
|
i = 0;
|
||||||
// {
|
while (line[i])
|
||||||
// (octet & i) ? printf("1") : printf("0");
|
{
|
||||||
// i >>= 1;
|
list->tetribit <<= 1;
|
||||||
// }
|
if (line[i] == '\n')
|
||||||
//}
|
i++;
|
||||||
|
if (line[i++] == '#')
|
||||||
|
list->tetribit |= 1;
|
||||||
|
}
|
||||||
|
while (!(list->tetribit & (1 << 15)))
|
||||||
|
list->tetribit <<= 1;
|
||||||
|
tmp = list->tetribit;
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
list->tibirtet <<= 1;
|
||||||
|
if (tmp & 1)
|
||||||
|
list->tibirtet |= 1;
|
||||||
|
tmp >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Function that creates the linked list and add a new structure
|
||||||
|
** linked each time needed
|
||||||
|
*/
|
||||||
|
|
||||||
|
int add_to_list(char *line, t_fillist **list)
|
||||||
|
{
|
||||||
|
t_fillist *tmp;
|
||||||
|
|
||||||
|
if (!(tmp = (t_fillist*)malloc(sizeof(*tmp))))
|
||||||
|
return (0);
|
||||||
|
if (!(*list))
|
||||||
|
tmp->next = NULL;
|
||||||
|
else
|
||||||
|
tmp->next = *list;
|
||||||
|
*list = tmp;
|
||||||
|
fill_list(line, *list);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** 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
|
||||||
@@ -41,7 +76,6 @@ void parse_input(char *input)
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
// printf("%s", input);
|
|
||||||
while (input[i])
|
while (input[i])
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
@@ -51,47 +85,8 @@ 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
|
|
||||||
** Function that parse a file and put each tetrimino in a linked list
|
|
||||||
*/
|
|
||||||
|
|
||||||
// char **create_square(char *tetri)
|
|
||||||
// {
|
|
||||||
// char **square;
|
|
||||||
// int i;
|
|
||||||
// int k;
|
|
||||||
//
|
|
||||||
// i = 0;
|
|
||||||
// if (!(square = (char**)malloc(sizeof(*square) * (4 + 1))))
|
|
||||||
// return (NULL);
|
|
||||||
// square[4] = NULL;
|
|
||||||
// while (*tetri && (k = -1))
|
|
||||||
// {
|
|
||||||
// if (!(square[i] = (char*)malloc(sizeof(**square) * (4 + 1))))
|
|
||||||
// return (NULL);
|
|
||||||
// square[i][4] = '\0';
|
|
||||||
// while (++k < 4)
|
|
||||||
// square[i][k] = *(tetri++);
|
|
||||||
// while (*tetri == '\n')
|
|
||||||
// tetri++;
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// return (square);
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -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/24 15:12:48 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Function that transforme a tetrminos char* into a short of 16 bites
|
** Function that transforme a tetrminos char* into a short of 16 bites
|
||||||
** then it fills it and its reverse into the list
|
** and then fills it and its reversed into the list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void fill_list(char line[], t_fillist *list)
|
void fill_list(char line[], t_fillist *list)
|
||||||
Reference in New Issue
Block a user