From fc02743cb082134226f332e0ec588ffff99896c1 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Sun, 14 Apr 2019 23:36:58 +0200 Subject: [PATCH] reduced tetraminos fonctionne mais pas a la norme --- srcs/.add_to_list.c.swp | Bin 12288 -> 12288 bytes srcs/add_to_list.c | 58 +++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/srcs/.add_to_list.c.swp b/srcs/.add_to_list.c.swp index 7f05fbb2001057583c93fee66b6aed9c40ceda61..ef2025ad1f3e98fb03cb2eaf1790ebd7bcb24339 100644 GIT binary patch delta 906 zcmaLTO=uHA6bJAZW2}29{j!Ndu~SHPlZG`}A_kgTuWg|R!4@GVG}=vemo$z0(Ju+9 zQc*9W4Ag@MTNFg>rNpWrR`8-{kA4&ndQ?GA3X1=vm{?H%C(f*|dB3%|vX!>hFD=b!H&MH1E1TtQ>_+*%Ky(jo!4h1AGE9R5 zlQ0HH;Ky#F53mWZUMqw}b;49jB39B#*Ghl!QIT(gP=z}=;p$GOryXQEO7eNdZ2!aIN z;Db(hvXkfn%)v*z-+OosFW@;mgAG`RRk#T&?zNQ(7r)|U2&#}Km z^(B7QufYCay6PDgjD`~1|4`(E4(I`YbLsbi%VqiXfK(Q0BNAb@YS|>rXnI~{!Ejh- z{VcCrwme|z^J-E_g|;fIbG=$;hncJ-8kt(uNEd8D|5uiT>h>M-fUVkQW>POqS=cSB z=kr_;MSfJ2`2(?^2PB2>3k>ZzoW!sga#Cu6F~S%rle*5;~TBb6Yb(Y8@-TP@^lE%e7@XsVvmY$l2;?aRK>%?Lct%fb!~c7=Ze_jGmVnNzl&)P@iplLFAEZXBpmFafWZb? zJUKvtMo0X#qdRtf!muVws22>=%r-C4aEo|o$~G*g5b4g_dY%c|h}9iq&ACQ}4~faX zR!hmap|gyj#RN^=)z>Iz6ty+B^O;m-UK7t8YmI9E23dah6_sR+U5839-n}w^A*Og% zih7L!z90$hvotelXsys2@`0d}Z6rW0*0YoUz0{=?qfvwnl*bKIXOSX1#Z28AbH +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/14 23:03:46 by hulamy ### ########.fr */ +/* Updated: 2019/04/14 23:36:01 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,7 +36,7 @@ void find_start_and_end(char **square, int *x1, int *x2, int *y1, int *y2) i--; } -char **fill_reduced_tetraminos(char **square, int x1, int y1, int x2, int y2) +char **fill_tetraminos(char **square, int x1, int y1, int x2, int y2) { char **result; int height; @@ -57,46 +57,38 @@ char **fill_reduced_tetraminos(char **square, int x1, int y1, int x2, int y2) i++; } i = -1; - while (++i < height && !(j = 0)) - while (j < length && (result[i][j] = '.')) - j++; + while (++i < height && (j = -1)) + while (++j < length) + result[i][j] = square[x1 + i][y1 + j]; return (result); } -void reduce_tetraminos(char **square, t_fillist *list) -{ - int x1; - int x2; - int y1; - int y2; - int i; - - 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); - list->size[0] = y2 - y1 + 1; - list->size[1] = x2 - x1 + 1; - printf("size [%d,%d]\n", list->size[0], list->size[1]); - list->area = list->size[0] * list->size[1]; - printf("area %d\n", list->area); - list->tetraminos = fill_reduced_tetraminos(square, x1, y1, x2, y2); - i = -1; - while (++i < list->size[1]) - printf("%s\n", list->tetraminos[i]); - -} - int add_to_list(char **square) { t_fillist *list; + int x1; + int x2; + int y1; + int y2; - square++; + x1 = -1; + y1 = -1; + x2 = 4; + y2 = 4; + square++; // pour test avec av** if (!(list = (t_fillist*)malloc(sizeof(*list)))) return (0); - reduce_tetraminos(square, list); + find_start_and_end(square, &x1, &x2, &y1, &y2); + list->size[0] = y2 - y1 + 1; + list->size[1] = x2 - x1 + 1; + list->area = list->size[0] * list->size[1]; + list->tetraminos = fill_tetraminos(square, x1, y1, x2, y2); + + int i; // test + i = -1; // test + while (++i < list->size[1]) // test + printf("%s\n", list->tetraminos[i]); // test + return (0); }