void ft_calcul_tetri(t_tetri **list) { char **map; double tmp; int size; t_pos p; t_nb nb; nb.nb_list = ft_count_tetri(*list); tmp = ft_sqrt(nb.nb_list * 4); size = tmp; if (tmp - size > 0.0) size++; map = ft_generate_map(size); nb.max = ft_strlen(map[0]); p.y = 0; p.x = 0; while (ft_place_tetri(*list, map, p, nb) == 0) { free(map); size++; map = ft_generate_map(size); nb.max = ft_strlen(map[0]); } ft_print_map(map); ft_clean_memory(list, map); }
int main(int ac, char **av) { char *buffer; int cnt_tetri; int ***tetri; int **map; ft_check_ac(ac); buffer = ft_get_file(av[1]); ft_check_file(buffer); cnt_tetri = ft_count_tetri(buffer); tetri = ft_split_tetri(buffer); map = ft_resol(tetri, cnt_tetri); ft_print_map(map); ft_free_map(map); map = NULL; ft_free_tetri(tetri, cnt_tetri); tetri = NULL; return (0); }