Compare commits
43 Commits
Mthandazo4
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
94a1cdaffc | ||
|
c672ca1205 | ||
|
ca1abc4990 | ||
|
ea99e7b1fc | ||
|
94145d3d17 | ||
|
f44cda2833 | ||
|
a21860983e | ||
|
5894c0cdd0 | ||
|
3156bddf27 | ||
|
a40b6b00e7 | ||
|
8552cf8a32 | ||
|
4bb3b45781 | ||
|
ee59b79e75 | ||
|
b22a1a5af7 | ||
|
a51c8ad81d | ||
|
6ad8cd2d95 | ||
|
9a386b315b | ||
|
ba1cea020d | ||
|
0b4c310374 | ||
|
5b4e0c0150 | ||
|
fe1c85371f | ||
|
c35deace58 | ||
|
a8b2e31701 | ||
|
c6339a00e9 | ||
|
bfb125f503 | ||
|
4a5c798b25 | ||
|
9b75432c2e | ||
|
d85e0873cb | ||
|
0495ba9e55 | ||
|
eb85b914a4 | ||
|
86b0530bf7 | ||
|
8c4a6aac25 | ||
|
5d094ebcaf | ||
|
fb66233265 | ||
|
3b893147e5 | ||
|
434b629055 | ||
|
08e622a4f0 | ||
|
a2fd180398 | ||
|
ae93873452 | ||
|
c36f501b08 | ||
|
0a9d7b816d | ||
|
ea0eda89d0 | ||
|
15669b7402 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "libft"]
|
||||
path = libft
|
||||
url = https://github.com/tvdu29/libft
|
26
Makefile
26
Makefile
@ -6,11 +6,11 @@
|
||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2019/03/27 16:51:02 by tmaze #+# #+# #
|
||||
# Updated: 2019/03/31 19:48:45 by tmaze ### ########.fr #
|
||||
# Updated: 2019/05/09 18:39:33 by tmaze ### ########.fr #
|
||||
# #
|
||||
#******************************************************************************#
|
||||
|
||||
NAME = lem_in
|
||||
NAME = lem-in
|
||||
|
||||
# Make options
|
||||
MAKEFLAGS += --no-print-directory
|
||||
@ -27,7 +27,7 @@ endif
|
||||
|
||||
# Compilator
|
||||
CC = gcc
|
||||
FLAGS = -Wall -Wextra -Werror -g -O0 -fsanitize=address
|
||||
FLAGS = -Wall -Wextra -Werror
|
||||
|
||||
# Folders
|
||||
LIBDIR = libft
|
||||
@ -36,7 +36,25 @@ OBJDIR = objs
|
||||
INCDIR = includes libft/includes
|
||||
|
||||
# Source files
|
||||
SRC = lem_in.c lm_parser.c lm_mem_utils.c lm_graph_utils.c lm_check_errors.c \
|
||||
SRC = lm_parser.c \
|
||||
lm_mem_utils.c \
|
||||
lm_check_errors.c \
|
||||
lm_data_utils.c \
|
||||
lm_initdata.c \
|
||||
lm_mem_utils.c \
|
||||
lm_graph_utils.c \
|
||||
lm_parser_error_check.c \
|
||||
lm_utils_parser.c \
|
||||
lm_utils_algo.c \
|
||||
bfs.c \
|
||||
lst_ind.c \
|
||||
edmonds_karp.c \
|
||||
push_ants.c \
|
||||
push_ants_utils.c \
|
||||
score_utils.c \
|
||||
print_map.c \
|
||||
lem_in.c
|
||||
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
|
BIN
Oglibft/.DS_Store
vendored
BIN
Oglibft/.DS_Store
vendored
Binary file not shown.
@ -6,16 +6,14 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/23 17:31:19 by tmaze #+# #+# */
|
||||
/* Updated: 2019/03/31 17:58:52 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/05/09 17:39:33 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LEM_IN_H
|
||||
# define LEM_IN_H
|
||||
|
||||
# include "libft.h"
|
||||
# include "limits.h"
|
||||
# include <fcntl.h>
|
||||
|
||||
typedef struct s_node
|
||||
{
|
||||
@ -34,99 +32,125 @@ typedef struct s_ind
|
||||
struct s_ind *next;
|
||||
} t_ind;
|
||||
|
||||
typedef struct s_lmdata
|
||||
{
|
||||
int nbants;
|
||||
int nb_nodes;
|
||||
t_list *nodes;
|
||||
t_node *nodes_data;
|
||||
t_ind **adj;
|
||||
} t_lmdata;
|
||||
|
||||
typedef struct s_bfs
|
||||
{
|
||||
int parent;
|
||||
char visited;
|
||||
char old_visited;
|
||||
int queue;
|
||||
} t_bfs;
|
||||
|
||||
//LEM_IN MT STRUCTS
|
||||
|
||||
typedef struct s_syntax
|
||||
typedef struct s_ants
|
||||
{
|
||||
int nb_ant;
|
||||
int nb_path;
|
||||
int nb_node;
|
||||
char end;
|
||||
struct s_ants *next;
|
||||
} t_ants;
|
||||
|
||||
typedef struct s_temp
|
||||
{
|
||||
int src_ind;
|
||||
int dest_ind;
|
||||
struct s_temp *next;
|
||||
} t_temp;
|
||||
|
||||
typedef struct s_holder
|
||||
{
|
||||
int count;
|
||||
int nb_state;
|
||||
int s_cmd;
|
||||
int s_pos;
|
||||
int error;
|
||||
int s_error;
|
||||
int state;
|
||||
int e_error;
|
||||
int v_error;
|
||||
int l_error;
|
||||
int gr_status;
|
||||
int s_vert;
|
||||
int e_vert;
|
||||
int gr_status;
|
||||
int e_cmd;
|
||||
int e_pos;
|
||||
int v_flag;
|
||||
} t_syntax;
|
||||
t_temp *data;
|
||||
} t_holder;
|
||||
|
||||
typedef struct s_AdjListNode
|
||||
typedef struct s_rdata
|
||||
{
|
||||
int dest;
|
||||
struct s_AdjListNode *next;
|
||||
} t_adjlist;
|
||||
char *line;
|
||||
struct s_rdata *next;
|
||||
} t_rdata;
|
||||
|
||||
typedef struct s_temp
|
||||
typedef struct s_lmdata
|
||||
{
|
||||
int src_ind;
|
||||
int dest_ind;
|
||||
struct s_temp *next;
|
||||
} t_temp;
|
||||
|
||||
typedef struct s_holder
|
||||
{
|
||||
int count;
|
||||
t_temp *data;
|
||||
} t_holder;
|
||||
|
||||
typedef struct s_AdjList
|
||||
{
|
||||
t_adjlist *head;
|
||||
} t_adj;
|
||||
|
||||
typedef struct s_graph
|
||||
{
|
||||
int v;
|
||||
t_adj *array;
|
||||
} t_graph;
|
||||
|
||||
typedef struct s_neighbour
|
||||
{
|
||||
int vertnum;
|
||||
struct s_neighbor *next;
|
||||
} t_neighbor;
|
||||
|
||||
//MT-FUNCTIONS
|
||||
int lm_error_exit(int flag);
|
||||
int lm_validate(t_syntax *synt, t_lmdata *lmdata);
|
||||
void lm_parser(int fd, t_syntax *synt, t_lmdata *ldata,
|
||||
t_holder *holder);
|
||||
int lm_check_room_before(char **tab, t_syntax *synt);
|
||||
void lm_init_data(t_syntax *synt, t_lmdata *ldata, t_holder *holder);
|
||||
int lm_add_vertex(t_lmdata *ldata, char *raw, char flag, t_syntax *synt);
|
||||
t_adjlist *lm_new_node(int dest);
|
||||
t_graph *lm_creategraph(int v);
|
||||
void lm_add_edge(t_graph *graph, int src, int dest);
|
||||
int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw);
|
||||
int lm_find_index(t_lmdata *data, char *str);
|
||||
|
||||
|
||||
int nbants;
|
||||
int nb_nodes;
|
||||
int nb_paths_max;
|
||||
t_node *nodes_data;
|
||||
t_ind **adj;
|
||||
t_rdata *map;
|
||||
} t_lmdata;
|
||||
|
||||
int lm_parser(t_lmdata *ldata
|
||||
, t_holder *holder);
|
||||
int lm_check_room_before(char **tab, t_holder *holder
|
||||
, char **name);
|
||||
void lm_clear_unv(t_holder *holder);
|
||||
int lm_add_vertex(t_lmdata *ldata, char *raw, char flag
|
||||
, t_holder *holder);
|
||||
int lm_ext_conn(t_holder *holder, t_lmdata *data
|
||||
, char *raw);
|
||||
void lm_ext_conn_sub(t_holder *holder, t_temp *new_data);
|
||||
int lm_init_src_dest(int *src, int *dest, t_lmdata *data
|
||||
, char *raw);
|
||||
int lm_find_index(t_lmdata *data, char *str);
|
||||
void lm_get_cmd_vertices(int count, t_holder *holder
|
||||
, t_lmdata *ldata, char *line);
|
||||
int lm_get_value(char *line);
|
||||
void lm_check_start_vert(int count, t_holder *hol
|
||||
, t_lmdata *ldata, char *line);
|
||||
void lm_check_end_vert(int count, t_holder *hol
|
||||
, t_lmdata *ldata, char *line);
|
||||
void lm_get_vert_link(int count, t_lmdata *ldata
|
||||
, t_holder *holder, char *line);
|
||||
int lm_validate_rooms(char *name, char *x, char *y);
|
||||
int lm_adj_parser(t_lmdata *lmdata, t_holder *holder);
|
||||
void lm_init_data(t_holder *holder, t_lmdata *ldata);
|
||||
int lm_verify_cmd(t_holder *holder, t_lmdata *data);
|
||||
void lm_initdata(t_lmdata *data);
|
||||
int lm_error_nbr(char *raw);
|
||||
int lm_getparams(t_lmdata *data);
|
||||
|
||||
|
||||
|
||||
void lm_clean_data(t_lmdata *data);
|
||||
int lm_check_forbiden_chars(char *line, int flag);
|
||||
t_ind **lst_indinit(t_lmdata *data);
|
||||
int lst_indadd_link(t_lmdata *data, int n1, int n2);
|
||||
t_ind *lst_indadd(t_ind **lst, int ind);
|
||||
void lst_inddel(t_ind **lst);
|
||||
void tablst_inddel(t_ind **tab);
|
||||
|
||||
void bfs(t_lmdata *data, t_bfs *tab, int start_ind, int end_ind);
|
||||
t_ind **edmunds_karp(t_lmdata *data, int start_ind, int end_ind);
|
||||
t_ants *add_ant(t_ants **ants, int nb_ant, int nb_path
|
||||
, t_ind **paths);
|
||||
void del_ants(t_ants **ants);
|
||||
t_node *get_node(t_lmdata *data, int index);
|
||||
t_ind *get_node_path(t_ind *lst, int index);
|
||||
|
||||
void bfs(t_lmdata *data, t_bfs *tab, int start_ind
|
||||
, int end_ind);
|
||||
t_ind **edmonds_karp(t_lmdata *data, int s_ind, int e_ind);
|
||||
int get_score(t_lmdata *data, t_ind **ret, int nb_paths);
|
||||
void print_paths(t_lmdata *data, t_ind **ret);
|
||||
int push_ants(t_lmdata *data, t_ind **paths
|
||||
, int nb_paths);
|
||||
void push_ants_end(t_lmdata *data, char *e_name);
|
||||
|
||||
void del_map(t_lmdata *data);
|
||||
int add_line_map(t_lmdata *data, char *line);
|
||||
void print_map(t_lmdata *data);
|
||||
|
||||
t_node *get_node_role(t_lmdata *data, char role);
|
||||
int get_nb_paths(t_ind **ret);
|
||||
void get_nb_paths_max(t_lmdata *data, int start, int end);
|
||||
|
||||
#endif
|
||||
|
1
libft
1
libft
@ -1 +0,0 @@
|
||||
Subproject commit 51295179f30451f2c2d6cbc8653c5accd9fb8a8a
|
@ -6,12 +6,12 @@
|
||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||
# Updated: 2019/03/27 17:46:28 by tmaze ### ########.fr #
|
||||
# Updated: 2019/05/09 18:39:42 by tmaze ### ########.fr #
|
||||
# #
|
||||
#******************************************************************************#
|
||||
|
||||
CC = gcc
|
||||
CCFLAGS = -Wall -Werror -Wextra -g -O0 -fsanitize=address
|
||||
CCFLAGS = -Wall -Werror -Wextra
|
||||
CCSTD =
|
||||
|
||||
NAME = libft.a
|
||||
@ -32,6 +32,7 @@ SRCS = ft_memalloc.c \
|
||||
ft_isascii.c \
|
||||
ft_isprint.c \
|
||||
ft_toupper.c \
|
||||
ft_isnumeric.c \
|
||||
ft_tolower.c \
|
||||
ft_isupper.c \
|
||||
ft_islower.c \
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
|
||||
/* Updated: 2019/03/20 16:46:41 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/26 10:36:51 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -266,6 +266,7 @@ int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||
int ft_atoi(const char *str);
|
||||
int ft_isalpha(int c);
|
||||
int ft_isdigit(int c);
|
||||
int ft_isnumeric(char *str);
|
||||
int ft_isalnum(int c);
|
||||
int ft_isascii(int c);
|
||||
int ft_isprint(int c);
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/04 11:33:35 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/04 11:34:10 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/29 11:16:40 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
29
libft/srcs/ft_isnumeric.c
Normal file
29
libft/srcs/ft_isnumeric.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isnumeric.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/26 10:17:04 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 11:20:54 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_isnumeric(char *str)
|
||||
{
|
||||
int index;
|
||||
|
||||
index = 0;
|
||||
if (str[index] == '-' || str[index] == '+')
|
||||
index++;
|
||||
while (str[index] != '\0')
|
||||
{
|
||||
if (!ft_isdigit(str[index]))
|
||||
return (0);
|
||||
index++;
|
||||
}
|
||||
return (1);
|
||||
}
|
@ -3,26 +3,22 @@
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/08 15:30:24 by tmaze ### ########.fr */
|
||||
/* Created: 2018/11/07 17:33:42 by mndhlovu #+# #+# */
|
||||
/* Updated: 2018/11/09 17:56:30 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <string.h>
|
||||
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
int i;
|
||||
int diff;
|
||||
size_t len;
|
||||
|
||||
i = 1;
|
||||
diff = (unsigned char)s1[0] - (unsigned char)s2[0];
|
||||
while (diff == 0 && s1[i - 1] && s2[i - 1])
|
||||
{
|
||||
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
|
||||
i++;
|
||||
}
|
||||
return (diff);
|
||||
len = 0;
|
||||
while (s1[len] && s2[len] && s1[len] == s2[len])
|
||||
len++;
|
||||
return ((unsigned char)s1[len] - (unsigned char)s2[len]);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user