First version with working test (read and print file)
This commit is contained in:
@@ -6,10 +6,13 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/03/01 13:35:08 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:13:35 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FILLIT_H
|
||||
# define FILLIT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> // for system call write
|
||||
#include <fcntl.h> // for system call open
|
||||
@@ -18,3 +21,18 @@
|
||||
#include <stdbool.h> // to use bool type
|
||||
|
||||
# define BUFFER_SIZE 1024
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVALUATION
|
||||
*/
|
||||
|
||||
void print_test(char *test);
|
||||
|
||||
/*
|
||||
** FUNCTIONS
|
||||
*/
|
||||
|
||||
char *read_file(char *file);
|
||||
void ft_display_error(char *s, int fd);
|
||||
|
||||
#endif
|
||||
|
||||
4
samples/42
Normal file
4
samples/42
Normal file
@@ -0,0 +1,4 @@
|
||||
4242
|
||||
4242
|
||||
4242
|
||||
4242
|
||||
19
samples/Non_valide
Normal file
19
samples/Non_valide
Normal file
@@ -0,0 +1,19 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
|
||||
.###
|
||||
...E
|
||||
....
|
||||
....
|
||||
|
||||
####
|
||||
####
|
||||
####
|
||||
####
|
||||
19
samples/Valide1
Normal file
19
samples/Valide1
Normal file
@@ -0,0 +1,19 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
BIN
samples/backslash_0
Normal file
BIN
samples/backslash_0
Normal file
Binary file not shown.
4
samples/bad_test
Normal file
4
samples/bad_test
Normal file
@@ -0,0 +1,4 @@
|
||||
.#..
|
||||
.#..
|
||||
###.
|
||||
....
|
||||
114
samples/difficile
Normal file
114
samples/difficile
Normal file
@@ -0,0 +1,114 @@
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.##.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
###.
|
||||
.#..
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.###
|
||||
..#.
|
||||
....
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
..#.
|
||||
..#.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
..#.
|
||||
..#.
|
||||
..##
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
####
|
||||
....
|
||||
114
samples/difficile_ou_pas
Normal file
114
samples/difficile_ou_pas
Normal file
@@ -0,0 +1,114 @@
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.##.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
###.
|
||||
.#..
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.###
|
||||
..#.
|
||||
....
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
..#.
|
||||
..#.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
..#.
|
||||
..#.
|
||||
..##
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
####
|
||||
....iskjdslkfsljklfdjk
|
||||
0
samples/empty
Normal file
0
samples/empty
Normal file
19
samples/full
Normal file
19
samples/full
Normal file
@@ -0,0 +1,19 @@
|
||||
###.
|
||||
#...
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
....
|
||||
#...
|
||||
###.
|
||||
|
||||
....
|
||||
.##.
|
||||
.##.
|
||||
....
|
||||
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
20
samples/invalid_sample
Normal file
20
samples/invalid_sample
Normal file
@@ -0,0 +1,20 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
|
||||
1
samples/newline
Normal file
1
samples/newline
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
4
samples/one
Normal file
4
samples/one
Normal file
@@ -0,0 +1,4 @@
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
4
samples/square
Normal file
4
samples/square
Normal file
@@ -0,0 +1,4 @@
|
||||
##..
|
||||
##..
|
||||
....
|
||||
....
|
||||
19
samples/sujet_1
Normal file
19
samples/sujet_1
Normal file
@@ -0,0 +1,19 @@
|
||||
....
|
||||
##..
|
||||
.#..
|
||||
.#..
|
||||
|
||||
....
|
||||
####
|
||||
....
|
||||
....
|
||||
|
||||
#...
|
||||
###.
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
##..
|
||||
.##.
|
||||
....
|
||||
39
samples/sujet_2
Normal file
39
samples/sujet_2
Normal file
@@ -0,0 +1,39 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
|
||||
....
|
||||
.##.
|
||||
.##.
|
||||
....
|
||||
|
||||
....
|
||||
....
|
||||
##..
|
||||
.##.
|
||||
|
||||
##..
|
||||
.#..
|
||||
.#..
|
||||
....
|
||||
|
||||
....
|
||||
###.
|
||||
.#..
|
||||
....
|
||||
34
samples/test7
Normal file
34
samples/test7
Normal file
@@ -0,0 +1,34 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
|
||||
....
|
||||
.##.
|
||||
.##.
|
||||
....
|
||||
|
||||
....
|
||||
....
|
||||
##..
|
||||
.##.
|
||||
|
||||
##..
|
||||
.#..
|
||||
.#..
|
||||
....
|
||||
54
samples/test_11
Normal file
54
samples/test_11
Normal file
@@ -0,0 +1,54 @@
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.##.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
###.
|
||||
.#..
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
39
samples/test_8
Normal file
39
samples/test_8
Normal file
@@ -0,0 +1,39 @@
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
.##.
|
||||
..#.
|
||||
..#.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
|
||||
....
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
4
samples/two
Normal file
4
samples/two
Normal file
@@ -0,0 +1,4 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
19
samples/valid_sample
Normal file
19
samples/valid_sample
Normal file
@@ -0,0 +1,19 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
20
samples/valid_sample_with_newline
Normal file
20
samples/valid_sample_with_newline
Normal file
@@ -0,0 +1,20 @@
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
...#
|
||||
|
||||
....
|
||||
....
|
||||
....
|
||||
####
|
||||
|
||||
.###
|
||||
...#
|
||||
....
|
||||
....
|
||||
|
||||
....
|
||||
..##
|
||||
.##.
|
||||
....
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:30:32 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:02:22 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *get_smallest_square(/*args*/)
|
||||
{
|
||||
/*backtracking*/
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:27:28 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:06:40 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
void ft_display_error(char *s, int fd)
|
||||
{
|
||||
write(fd, s, strlen(s));
|
||||
}
|
||||
|
||||
int ft_tetri_erros(/*args*/)
|
||||
/*
|
||||
int ft_tetri_erros()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:27:42 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:13:42 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *input;
|
||||
@@ -19,8 +21,8 @@ int main(int argc, char **argv)
|
||||
{
|
||||
if (!(input = read_file(argv[1])))
|
||||
ft_display_error("Error: Could not read file.\n", 2);
|
||||
else if (/*Elements in file not valid*/)
|
||||
ft_display_error("Error: Invalid file.\n", 2);
|
||||
// else if (/*Elements in file not valid*/)
|
||||
// ft_display_error("Error: Invalid file.\n", 2);
|
||||
/*
|
||||
Transform input to tetriminos
|
||||
Check if every tetrimino is valid
|
||||
@@ -28,6 +30,7 @@ int main(int argc, char **argv)
|
||||
Transform tetriminos with letters
|
||||
Print result
|
||||
*/
|
||||
print_test(input);
|
||||
}
|
||||
else
|
||||
ft_display_error("Error: Please submit a file.\n", 2);
|
||||
|
||||
@@ -6,11 +6,20 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:35:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:26:27 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:13:16 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_print_fillit(/*args*/)
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
/*
|
||||
void ft_print_fillit()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void print_test(char *test)
|
||||
{
|
||||
write(1, test, strlen(test));
|
||||
}
|
||||
|
||||
36
srcs/read_file.c
Normal file
36
srcs/read_file.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* read_file.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/14 12:08:12 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *read_file(char *file)
|
||||
{
|
||||
char buf[BUFFER_SIZE];
|
||||
int fd;
|
||||
int rv;
|
||||
int i;
|
||||
char *result;
|
||||
|
||||
if (((fd = open(file, O_RDONLY)) < 0) \
|
||||
|| ((rv = read(fd, &buf, BUFFER_SIZE)) < 0) \
|
||||
|| !(result = malloc(sizeof(char))))
|
||||
return (NULL);
|
||||
buf[rv] = '\0';
|
||||
i = 0;
|
||||
while (rv--)
|
||||
{
|
||||
result[i] = buf[i];
|
||||
i++;
|
||||
}
|
||||
close(fd);
|
||||
return (result);
|
||||
}
|
||||
@@ -6,11 +6,13 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/12 22:31:30 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:31:51 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:08:58 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *tetri_to_letters(/*args*/)
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *tetri_to_letters()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user