fillit/inc/fillit.h
2016-12-22 05:49:27 +02:00

112 lines
3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fillit.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/14 16:42:06 by gtertysh #+# #+# */
/* Updated: 2016/12/20 19:18:00 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FILLIT_H
# define FILLIT_H
#include "libft.h"
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h> // warning!
# define BUF_S 8192
typedef struct s_coord
{
int y;
int x;
} t_coord;
typedef struct s_ttrmn
{
char t[17];
int width;
int height;
t_coord c[4];
} t_ttrmn;
typedef struct s_node
{
struct s_node *left;
struct s_node *right;
struct s_node *up;
struct s_node *down;
struct s_node *column;
t_coord coord;
int type;
int size;
} t_node;
extern t_ttrmn g_templates[19];
// reads from file
char *read_file(char *path);
// convert string to table by spliting by '\n'
char **to_table(char **string);
// print table returned by to_table()
void print_table(char **table);
// creates new table where each string represent whole figrure
char **glue_figure(char **table);
// move tetromino in top left corner
void move_up_left(char **table);
// print table returned by glue_figure()
void print_one_string(t_ttrmn ttr);
// compare 19 templates with each tetromino in *ttr table
void test_check(char **ttr, t_ttrmn *tamplates);
// change hashes ('#') with letters
// obsolete, rewrite for structs array
void to_letters(char **ttr);
t_node *init_root(int size);
t_node *add_column(t_node *root);
t_node **add_cols(t_node *root, int number);
t_node *add_node(t_node *col);
t_node *add_node_with_coord(t_node *col, t_coord row, int type);
t_node **add_cols(t_node *root, int number);
void print_solution(t_list *sol, t_node *root, int amount);
void add_rows(int *types, int amount, int size, t_node **cols_arr);
void link_row(int *col_nums, t_node **cols_arr);
void add_row(int *col_numbers, t_node **cols_arr, t_coord coord, int type);
void search(t_node* root, t_list *solution, int k, int amount);
void cover(t_node *to_cover);
void uncover(t_node *to_uncover);
int *get_types(char **ttr);
int get_amount(char **ttr);
unsigned int ft_sqrt_ceil(unsigned int num);
void fill_map(char *map, int size, t_node *ttr, int letter);
#endif