From 4ad02074b6385a8d0309009857b3fb84cb28917c Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Sun, 14 Apr 2019 22:10:35 +0200 Subject: [PATCH] find start and end fonctionne --- includes/.fillit.h.swp | Bin 12288 -> 0 bytes srcs/add_to_list.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) delete mode 100644 includes/.fillit.h.swp diff --git a/includes/.fillit.h.swp b/includes/.fillit.h.swp deleted file mode 100644 index 599640c64f4e1278de8501352f656144c6ffeac4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/srcs/add_to_list.c b/srcs/add_to_list.c index 1aa0a87..e91316b 100644 --- a/srcs/add_to_list.c +++ b/srcs/add_to_list.c @@ -6,28 +6,49 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/14 19:11:50 by hulamy ### ########.fr */ +/* Updated: 2019/04/14 22:03:19 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/fillit.h" #include -int find_start_and_end(char *square) + +void find_start_and_end(char **square, int *x1, int *x2, int *y1, int *y2) { int i; + i = 4; + while (*x1 < 4 && i == 4 && !(i = 0) && square[++(*x1)][0] != '#') + while (i < 4 && square[*x1][i] != '#') + i++; + i = 4; + while (*y1 < 4 && i == 4 && !(i = 0) && square[0][++(*y1)] != '#') + while (i < 4 && square[i][*y1] != '#') + i++; i = -1; - while (++i < 4) - printf("%c",square[0] + i); - return (i); + while (*x2 >= 0 && i == -1 && (i = 3) && square[--(*x2)][3] != '#') + while (i >= 0 && square[*x2][i] != '#') + i--; + i = -1; + while (*y2 >= 0 && i == -1 && (i = 3) && square[3][--(*y2)] != '#') + while (i >= 0 && square[i][*y2] != '#') + i--; } void reduce_tetraminos(char **square, t_fillist *list) { - int start; + int x1; + int x2; + int y1; + int y2; - start = find_start_and_end(square[1]); + x1 = -1; + y1 = -1; + x2 = 4; + y2 = 4; + find_start_and_end(square, &x1, &x2, &y1, &y2); + printf("de [%d,%d] a [%d,%d]\n",x1, y1, x2, y2); (void)list; }