Skip to content

Commit

Permalink
[+] Add all files
Browse files Browse the repository at this point in the history
  • Loading branch information
toro-nicolas committed Jun 17, 2024
1 parent abf12c5 commit 35bc48a
Show file tree
Hide file tree
Showing 125 changed files with 7,621 additions and 2 deletions.
160 changes: 160 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
##
## EPITECH PROJECT, 2023
## settingup
## File description:
## The main Makefile of our project
##

NAME = setting_up

MAIN = src/create_map.c \
src/edit_map.c \
src/error_handling.c \
src/get_size.c \
src/place_square.c \
src/main.c

SRC = ./lib/my/my_array_of_array_len.c \
./lib/my/my_compute_factorial_rec.c \
./lib/my/my_compute_power_rec.c \
./lib/my/my_compute_square_root.c \
./lib/my/my_concat_params.c \
./lib/my/my_convert_base.c \
./lib/my/my_convert_base_unsigned.c \
./lib/my/my_find_prime_sup.c \
./lib/my/my_getnbr.c \
./lib/my/my_getnbr_base.c \
./lib/my/my_isneg.c \
./lib/my/my_is_prime.c \
./lib/my/my_params_to_array.c \
./lib/my/my_print_combn.c \
./lib/my/my_print_params.c \
./lib/my/my_put_nbr.c \
./lib/my/my_putchar.c \
./lib/my/my_putnbr_base.c \
./lib/my/my_putstr.c \
./lib/my/my_putstr_error.c \
./lib/my/my_putstr_sized.c \
./lib/my/my_rev_params.c \
./lib/my/my_revstr.c \
./lib/my/my_show_param_array.c \
./lib/my/my_show_word_array.c \
./lib/my/my_showmem.c \
./lib/my/my_showstr.c \
./lib/my/my_sort_int_array.c \
./lib/my/my_sort_params.c \
./lib/my/my_str_isalpha.c \
./lib/my/my_str_islower.c \
./lib/my/my_str_isnum.c \
./lib/my/my_str_isprintable.c \
./lib/my/my_str_isupper.c \
./lib/my/my_str_nbr.c \
./lib/my/my_str_nbr_base_unsigned.c \
./lib/my/my_str_nbr_base_long_long_int.c \
./lib/my/my_str_nbr_unsigned.c \
./lib/my/my_str_nbr_unsigned_long.c \
./lib/my/my_str_nbr_long_long.c \
./lib/my/my_str_nbr_size_t.c \
./lib/my/my_str_to_word_array.c \
./lib/my/my_strcapitalize.c \
./lib/my/my_strcat.c \
./lib/my/my_strcmp.c \
./lib/my/my_strcpy.c \
./lib/my/my_strdup.c \
./lib/my/my_strlen.c \
./lib/my/my_strlowcase.c \
./lib/my/my_strncat.c \
./lib/my/my_strncmp.c \
./lib/my/my_strncpy.c \
./lib/my/my_strstr.c \
./lib/my/my_strupcase.c \
./lib/my/my_swap.c \
./lib/my/flags/flag_c.c \
./lib/my/flags/flag_s.c \
./lib/my/flags/flag_d.c \
./lib/my/flags/flag_i.c \
./lib/my/flags/flag_p.c \
./lib/my/flags/flag_o.c \
./lib/my/flags/flag_u.c \
./lib/my/flags/flag_x.c \
./lib/my/flags/flag_bigx.c \
./lib/my/flags/flag_e.c \
./lib/my/flags/flag_bige.c \
./lib/my/flags/flag_f.c \
./lib/my/flags/flag_bigf.c \
./lib/my/flags/flag_g.c \
./lib/my/flags/flag_bigg.c \
./lib/my/flags/flag_a.c \
./lib/my/flags/flag_biga.c \
./lib/my/flags/flag_n.c \
./lib/my/flags/flag_m.c \
./lib/my/flags/flag_b.c \
./lib/my/flags/flag_bigs.c \
./lib/my/flags/flag_bigd.c \
./lib/my/flags/flag_percent.c \
./lib/my/flags/find_format.c \
./lib/my/flags/get_format.c \
./lib/my/flags/my_show_formating.c \
./lib/my/flags/sub_format_double.c \
./lib/my/flags/format_it_int.c \
./lib/my/flags/format_it_double.c \
./lib/my/flags/precise_it_int.c \
./lib/my/flags/precise_it_double.c \
./lib/my/flags/format_it_str.c \
./lib/my/flags/format_it_char.c \
./lib/my/flags/sub_format_int.c \
./lib/my/flags/sub_format_str.c \
./lib/my/flags/sub_format_char.c \
./lib/my/flags/specifier_int.c \
./lib/my/flags/specifier_base.c \
./lib/my/my_printf.c

MAIN-OBJ = $(MAIN:.c=.o)

OBJ = $(SRC:.c=.o)

CFLAGS += -Werror -Wextra -Wpedantic -O3
CFLAGS += -I./include/

LDFLAGS += -L./lib/my -lmy

TEST_FLAGS += --coverage -lcriterion -lgcov

VALGRIND_FLAGS += -g3

all: libmy.a $(NAME)

libmy.a:
@make -C./lib/my/

$(NAME): $(MAIN-OBJ)
@gcc -o $(NAME) $(MAIN-OBJ) $(CFLAGS) $(LDFLAGS)

test: re
@./$(NAME) 6 "..oo."

valgrind: fclean libmy.a $(MAIN-OBJ)
@gcc -o $(NAME) $(MAIN-OBJ) $(VALGRIND_FLAGS) $(CFLAGS) $(LDFLAGS)
@valgrind -s ./$(NAME) 6 "..oo."

clean:
@rm -f $(OBJ)
@rm -f $(MAIN-OBJ)

fclean: clean
@make fclean -C./lib/my/
rm -rf ./lib/libmy.a
rm -rf libmy.a
rm -rf a.out
rm -rf unit_tests*
rm -rf vgcore*
rm -rf $(NAME)

re: fclean all

unit_tests: re
@gcc -o unit_tests $(SRC) tests/*.c $(LDFLAGS) $(TEST_FLAGS)

tests_run: unit_tests
@./unit_tests
@gcovr
120 changes: 118 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,118 @@
# setting_up
A algorithmic project in C consisting in finding the largest square in a map as quickly as possible.
# Setting Up 📏

## Table of contents 📑
- [Description](https://github.com/toro-nicolas/setting-up/blob/main/README.md#description-)
- [Usage](https://github.com/toro-nicolas/setting-up/blob/main/README.md#usage-%EF%B8%8F)
- [Result](https://github.com/toro-nicolas/setting-up/blob/main/README.md#result-)
- [Compilation](https://github.com/toro-nicolas/setting-up/blob/main/README.md#compilation-%EF%B8%8F)
- [Code mandatory](https://github.com/toro-nicolas/setting-up/blob/main/README.md#code-mandatory-)
- [What's next ?](https://github.com/toro-nicolas/setting-up/blob/main/README.md#whats-next--)
- [Contributors](https://github.com/toro-nicolas/setting-up/blob/main/README.md#contributors-)


## Description 📝
The **Setting Up** is a project carried out in **solo**, during our **1st year** in [**EPITECH**](https://www.epitech.eu/) Grand Ecole program.
Its purpose is to create in [**C**](https://en.wikipedia.org/wiki/C_(programming_language)) a program to **find the largest square in a zone**.


## Usage ⚔️
You can run the setting-up like this :
- Map resolution :
```sh
./setting-up exemple_files/maps/intermediate_map_100_100
```
- Map generation and resolution :
```sh
./setting_up 10000 "......o.."
```


## Result 🚩
The result of this project is a **perfect Setting Up**.
If you discover a **problem** or an **error**, don't hesitate to **create an issue** and **report it** to us as soon as possible.


### my.epitech.eu result

| Category | Percentage | Numbers of tests | Crash |
|-----------------------------------------|:----------:|:----------------:|:--------:|
| Algorithm app. - Generating column | 100% | 8/8 | No |
| Algorithm app. - Generating edges | 100% | 4/4 | No |
| Algorithm app. - Generating line | 100% | 7/7 | No |
| Algorithm app. - Generating square | 100% | 3/3 | No |
| Algorithm app. - Opening column | 100% | 7/7 | No |
| Algorithm app. - Opening edges | 100% | 7/7 | No |
| Algorithm app. - Opening line | 100% | 7/7 | No |
| Algorithm app. - Opening rectangle | 100% | 7/7 | No |
| Basics | 100% | 7/7 | No |
| Data structure - Generating | 100% | 7/7 | No |
| Data structure - Opening | 100% | 7/7 | No |
| Optimization - Generating 100 to 500 | 100% | 7/7 | No |
| Optimization - Generating 1000 to 2000 | 100% | 7/7 | No |
| Optimization - Generating 5000 to 10000 | 100% | 7/7 | No |
| Optimization - Opening 100 to 500 | 100% | 7/7 | No |
| Optimization - Opening 1000 to 2000 | 100% | 7/7 | No |
| Optimization - Opening 5000 to 10000 | 100% | 7/7 | No |
| Parsing - Opening | 100% | 7/7 | No |
| Robustness - Generating empty map | 100% | 7/7 | No |
| Robustness - Generating filled map | 100% | 7/7 | No |
| Robustness - Generating valid board | 100% | 7/7 | No |
| Robustness - Opening empty map | 100% | 7/7 | No |
| Robustness - Opening filled map | 100% | 7/7 | No |
| Robustness - Opening valid file | 100% | 7/7 | No |
| **Results** | **100%** | **29/29** | **No** |


### Tests and code coverage
**Unit tests** were performed using [criterion](https://criterion.readthedocs.io/en/master/intro.html).
In this project, **only** the **library code is covered**.
Unit tests are still to be performed, but a large part of the code is already covered.

You can compile the project and run the unit tests with this command :
```sh
make tests_run
```


## Compilation 🛠️
You can compile the project with this command :
```sh
make
```

If you want clean the project, you can run this command :
```sh
make fclean
```

You can clean and compile the project with ```make re```.

You can compile the unit tests with this command :
```sh
make unit_tests
```


## Code mandatory 📦
- You'll need to create a branch where you'll push your code. Once you've completed your tasks on this branch, we'll work together to merge it and check that everything works.
- Every function you add must be code-style.
- Before merging, you'll need to check that all unit tests pass by running ```make tests_run```.
- Each commit will contain ```[+]``` or ```[-]``` or ```[~]``` followed by a message
- ```[+]``` : Add feature
- ```[-]``` : Delete feature
- ```[~]``` : Edit feature

**Of course, in exceptional cases, we may depart from these rules.**


## What's next ? 🚀
- Add help section
- Add a graphical visualization
- Add github actions
- Improve the memory management
- Add a documentation for each function
- Add unit tests on each piece of code


## Contributors 👤
This project was carried out alone by [**Nicolas TORO**](https://github.com/toro-nicolas).
95 changes: 95 additions & 0 deletions include/my.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
** EPITECH PROJECT, 2023
** Libmy
** File description:
** Store libmy functions prototypes
*/

#include <stddef.h>

#ifndef MY_H_
#define MY_H_
#define ABS(value) ((value < 0) ? - value : value)

struct info_param {
int length;
char *str;
char *copy;
char **word_array;
};

int my_printf(char const *format, ...);
void my_putchar(char c);
int my_isneg(int nb);
int my_put_nbr(int nb);
void my_swap(int *a, int *b);
int my_putstr(char const *str);
int my_strlen(char const *str);
int my_getnbr(char const *str);
void my_sort_int_array(int *tab, int size);
int my_compute_power_rec(int nb, int power);
int my_compute_square_root(int nb);
int my_is_prime(int nb);
int my_find_prime_sup(int nb);
char *my_strcpy(char *dest, char const *src);
char *my_strncpy(char *dest, char const *src, int n);
char *my_revstr(char *str);
char *my_strstr(char *str, char const *to_find);
int my_strcmp(char const *s1, char const *s2);
int my_strncmp(char const *s1, char const *s2, int n);
char *my_strupcase(char *str);
char *my_strlowcase(char *str);
char *my_strcapitalize(char *str);
int my_str_isalpha(char const *str);
int my_str_isnum(char const *str);
int my_str_islower(char const *str);
int my_str_isupper(char const *str);
int my_str_isprintable(char const *str);
int my_showstr(char const *str);
int my_showmem(char const *str, int size);
char *my_strcat(char *dest, char const *src);
char *my_strncat(char *dest, char const *src, int nb);

int my_print_combn(int n);
int my_compute_factorial_rec(int nb);
int my_putnbr_base(int nbr, char const *base);
int my_getnbr_base(char const *str, char const *base);
void my_print_params(int argc, char **argv);
void my_rev_params(int argc, char **argv);
void my_sort_params(int argc, char **argv);
char *my_strdup(const char *src);
char *my_concat_params(int argc, char **argv);
int my_show_word_array(char *const *tab);
char **my_str_to_word_array(char const *str);
char *my_convert_base(char const *nbr,
char const *base_from, char const *base_to);
char *my_convert_base_unsigned(char const *nbr,
char const *base_from, char const *base_to);
char *my_convert_base_size_t(char const *nbr,
char const *base_from, char const *base_to);
struct info_param *my_params_to_array(int ac, char **av);
int my_show_param_array(struct info_param const *par);
int my_array_of_array_len(char **array);
int my_putstr_error(char const *str);
int my_putstr_sized(char const *str, int size);
size_t my_compute_power_rec_size_t(int nb, int p);
void my_round_float_str(char *float_nb, char last_char, int i, int enable);
int my_char_isprintable(char const c);

char *my_str_nbr(int nb);
char *my_str_nbr_short(short int nb);
char *my_str_nbr_short_short(signed char nb);
char *my_str_nbr_base_unsigned(unsigned int nbr, char const *base);
char *my_str_nbr_base_unsigned_short(unsigned short nbr, char const *base);
char *my_str_nbr_base_unsigned_short_short(unsigned char nbr,
char const *base);
char *my_str_nbr_base_unsigned_size_t(size_t nbr, char const *base);
char *my_str_nbr_base_unsigned_long(unsigned long nbr, char const *base);
char *my_str_nbr_base_long_long_int(long long int nbr, char const *base);

char *my_str_nbr_unsigned(unsigned int nb);
char *my_str_nbr_unsigned_long(unsigned long int nb);
char *my_str_nbr_long_long(long long nb);
char *my_str_nbr_size_t(size_t nb);

#endif /* MY_H_ */
Loading

0 comments on commit 35bc48a

Please sign in to comment.