From 94fcafd8d67efce7f379b02bbd02720defb596e1 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Sun, 14 Apr 2019 17:31:36 +0200 Subject: [PATCH] premiere tentative qui ne rend pas la bon carre autour du tetraminos --- includes/.fillit.h.swp | Bin 0 -> 12288 bytes includes/fillit.h | 11 +++++++- srcs/add_to_list.c | 60 +++++++++++++++++++++++++++++++++++++++++ srcs/main.c | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 includes/.fillit.h.swp create mode 100644 srcs/add_to_list.c diff --git a/includes/.fillit.h.swp b/includes/.fillit.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..599640c64f4e1278de8501352f656144c6ffeac4 GIT binary patch literal 12288 zcmeI2-;Ucv7{$L6>wg=0td zc-s^KHx%&}T);gS+*RCy#0&5YJOB^C8UI;(E3w)YdsFF~=)~ihGiPRgNu)%XS?|vH z6S3YM5Xvh=+4WyPd-~)QJ$;L4Ckx%hN_QMwq@CDHYtS9oT|YU%`b`mN`f--1m3kPP zy$`niAPfU#2GKmsJeiuseRt=89PVNQOyGzFGUdO2X^r}})zc%}Z(b0uo|_&qgzZd# z2`~XBzyz286JP>NfC)U$1k~~beTxm8EH{z=I6(bGd0$=2TfQ&>Ccp%k025#WOn?b6 z0Vco%m;e)C0?#1<*CXn*h+aI6#pD0~>i7RIXNm4ZYtV0Jh`xl*Lw~LjJ%Zkb{(70{ z3G^M5LN4?LG=biL{&|V$59mi|7s{Y}&|TSaPQ4WluzX6Ym(bCN#Z1ZM~4anhehSP8?+k-UTc}aS9F)X>3afA z!uMdw7hxpQ_4GdE{_$j(WEic{^v1QV@y#2z$u#hdwGLG>Rpkg>MO-=J`fxJb8j8)~ z=;p1V7~Z)$nO@Zic|coWLqR0P=5#a~-rBxBzB?3F&&E;Pc6r=YTuzlYi{r4nb48e@ zP_f8TDRhg_MD`nlxU~6kg6vuLK;)bD_t}8qLBqF@i$%OEg&TPqZYZOM+n-0Onp=ma zt5nH_n7d&p;^jVT76n*qBe>~(m;~yX#fHHQW^A>hFd9!LQ!8>*7H%Sa8^4~#fk4L^|(Bw<5WqF%qp<<9>O`!wOs@i~^Wuk$(>AB$6z;N8 hT&ln$1l3l@sUlI+1zrCuu#T>4Mc}c0Q1GEM>0cfhj-~(r literal 0 HcmV?d00001 diff --git a/includes/fillit.h b/includes/fillit.h index 5be5d50..b964110 100644 --- a/includes/fillit.h +++ b/includes/fillit.h @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 14:31:26 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 16:32:21 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,4 +36,13 @@ char *read_file(char *file); void print_error(char *s, int fd); int ft_file_errors(char *file); +typedef struct s_fillist +{ + int id; + char **tetraminos; + int position[2]; + int size[2]; + struct s_fillist *next; +} t_fillist; + #endif diff --git a/srcs/add_to_list.c b/srcs/add_to_list.c new file mode 100644 index 0000000..05f5f11 --- /dev/null +++ b/srcs/add_to_list.c @@ -0,0 +1,60 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* add_to_list.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ +/* Updated: 2019/04/14 17:30:57 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/fillit.h" +#include + +void find_start_to_end(char **square, int *x1, int *x2, int *y1, int *y2) +{ + while (*y1 == 4 && !(*y1 = 0) && square[++(*x1)][0] != '#') + while (*y1 < 4 && square[*x1][*y1] != '#') + (*y1)++; + while (*y2 == 0 && (*y2 = 3) && square[--(*x2)][3] != '#') + while (*y2 > 0 && square[*x2][*y2] != '#') + (*y2)--; +} + +void reduce_tetraminos(char **square, t_fillist *list) +{ + int x1; + int x2; + int y1; + int y2; + + x1 = -1; + x2 = 4; + y1 = 4; + y2 = 0; + find_start_to_end(square, &x1, &x2, &y1, &y2); + printf("de [%d,%d] a [%d,%d]\n",x1, y1, x2, y2); +} + +int add_to_list(char **square) +{ + t_fillist *list; + + square++; + printf("square[0] : %s\n", square[0]); + if (!(list = (t_fillist*)malloc(sizeof(*list)))) + return (0); + reduce_tetraminos(square, list); + return (0); +} + +int main(int ac, char **av) +{ + if (ac == 5) + { + add_to_list(av); + } + return (0); +} diff --git a/srcs/main.c b/srcs/main.c index 77a239f..db049da 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 14:39:28 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 15:18:46 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */