-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashes.c
executable file
·88 lines (77 loc) · 1.91 KB
/
hashes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hashes.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vportell <vportell@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/09 21:00:05 by stati #+# #+# */
/* Updated: 2016/11/13 11:13:01 by vportell ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
t_piece *update_hash(unsigned int i, int *x, int *y)
{
t_piece *new;
new = malloc(sizeof(t_piece));
if (new)
{
if (x == NULL || y == NULL)
{
new->x = NULL;
new->y = NULL;
new->type = 0;
}
else
{
new->type = (char)(i + 65);
if (!(new->x = ft_memalloc(4 * 4))
|| !(new->y = ft_memalloc(4 * 4)))
return (NULL);
new->x = (int*)ft_memcpy(new->x, x, 4 * 4);
new->y = (int*)ft_memcpy(new->y, y, 4 * 4);
get_max(&new);
}
new->next = NULL;
}
return (new);
}
void add_hash(t_piece **blst, t_piece *lst)
{
t_piece *tmp;
tmp = *blst;
while (tmp->next)
tmp = tmp->next;
tmp->next = lst;
}
int bestfinder(int *ary)
{
int i;
int num;
i = 3;
num = 0;
while (i > -1)
{
if (ary[i] > num)
num = ary[i];
i--;
}
return (num);
}
void get_max(t_piece **lst)
{
t_piece *new;
new = *lst;
new->w = bestfinder(new->x);
new->h = bestfinder(new->y);
}
void print_plan(char **board, unsigned int size)
{
unsigned int i;
i = 0;
while (i < size)
{
ft_putendl(board[i]);
i++;
}
}