diff --git a/cpp00/ex01/Makefile b/cpp00/ex01/Makefile index 06122d1..c5b6a69 100644 --- a/cpp00/ex01/Makefile +++ b/cpp00/ex01/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/10/10 17:59:41 by rparodi ### ########.fr # +# Updated: 2025/02/10 10:02:41 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -113,7 +113,7 @@ footer: @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' clangd: - @printf \ + @echo \ "CompileFlags:\n" \ " Add:\n" \ " - \"-std=c++98 -Wall -Wextra -Werror\"\n" \ diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index b3f9740..f27eb28 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/06/07 16:45:53 by rparodi ### ########.fr # +# Updated: 2025/05/02 15:21:09 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -53,23 +53,12 @@ END = \033[0m all: header $(NAME) footer get_db: - @rm -rf ./cpp_09.tgz ./cpp_09 ./data.csv > /dev/null - @wget https://cdn.intra.42.fr/document/document/33121/cpp_09.tgz > /dev/null - @tar -xvf cpp_09.tgz > /dev/null - @cp ./cpp_09/data.csv . > /dev/null - @rm -rf ./cpp_09.tgz ./cpp_09 > /dev/null + @rm -rf ./cpp_09.tgz ./cpp_09 ./data.csv &> /dev/null + @wget https://cdn.intra.42.fr/document/document/33121/cpp_09.tgz &> /dev/null + @tar -xvf cpp_09.tgz &> /dev/null + @cp ./cpp_09/data.csv . &> /dev/null + @rm -rf ./cpp_09.tgz ./cpp_09 &> /dev/null @printf '$(GREY)Downloaded $(END)$(GREEN)data.csv$(END)\n' - @echo "date | value" > ./input.txt - @echo "2011-01-03 | 3" >> ./input.txt - @echo "2011-01-03 | 2" >> ./input.txt - @echo "2011-01-03 | 1" >> ./input.txt - @echo "2011-01-03 | 1.2" >> ./input.txt - @echo "2011-01-09 | 1" >> ./input.txt - @echo "2012-01-11 | -1" >> ./input.txt - @echo "2001-42-42" >> ./input.txt - @echo "2012-01-11 | 1" >> ./input.txt - @echo "2012-01-11 | 2147483648" >> ./input.txt - @printf '$(GREY)Writing the example $(END)$(GREEN)input.txt$(END)\n' # Clean (make clean) clean: @@ -86,9 +75,6 @@ fclean: clean # Restart (make re) re: header fclean all -run: all - @./$(NAME) ./input.txt - # Dependences for all $(NAME): $(OBJ) @mkdir -p $(OBJDIRNAME) @@ -117,7 +103,7 @@ header: @printf '$(GOLD) ****** $(END)\n' @printf '$(GREY) Made by rparodi$(END)\n\n' -debug: CPPFLAGS += -D DEBUG=1 -g +debug: CPPFLAGS += -D DEBUG=1 debug: re # Footer @@ -150,5 +136,5 @@ clangd: @printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n' # Phony -.PHONY: all clean fclean re get_db clangd run +.PHONY: all clean fclean re get_db clangd -include ${OBJ:.o=.d} diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index 9a96d3b..1982e94 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/06/08 15:59:57 by rparodi ### ########.fr */ +/* Updated: 2025/05/02 15:22:16 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -127,13 +127,9 @@ std::string check_date(std::string name, enum error_code *error_code) { return (name); } std::string day = name.substr(8, 2); - if (year < "2009" || (year == "2009" && month <= "01" && day < "02")) { - *error_code = NO_DATE; - return (name); - } if (day > "28") { if (month == "02" && day == "29") { - if (!((atoi(year.c_str()) % 4 == 0) && (atoi(year.c_str()) % 100 != 0 || atoi(year.c_str()) % 400 == 0))) + if ((atoi(year.c_str()) % 4 == 0) && (atoi(year.c_str()) % 100 != 0 || atoi(year.c_str()) % 400 == 0)) *error_code = NO_DATE; } else { @@ -141,8 +137,6 @@ std::string check_date(std::string name, enum error_code *error_code) { for (int i = 0; i < 4; i++) { if (month == month_30[i] && day > "30") { *error_code = NO_DATE; - } else if (day > "31") { - *error_code = NO_DATE; } } } @@ -194,7 +188,7 @@ std::mapparse_input(std::string name) { std::string tmpLine; std::string tmpDate; - float tmpValue = 0; + float tmpValue = 0; std::getline(file, tmpLine); if (tmpLine != "date | value") { @@ -221,12 +215,15 @@ std::mapparse_input(std::string name) { } void print_result(std::map input, std::map db) { + std::map::iterator it_input = input.begin(); std::map::iterator it_db = db.begin(); - for (std::map::iterator it_input = input.begin(); it_input != input.end(); it_input++) { + while (it_input != input.end()) { if (it_input->second.reason == NO_ERROR) { - while (it_db != db.end() && it_input->second.date > it_db->first) { + while (it_db != db.end() && it_input->second.date > it_db->first) it_db++; + if (it_db == db.begin()) { + it_db--; } if (it_db == db.end()) { std::cerr << CLR_MAGENTA << it_input->second.date << CLR_RED << " => no data found" << CLR_RESET << std::endl; @@ -258,6 +255,7 @@ void print_result(std::map input, std::map db break; } } + it_input++; } } diff --git a/cpp09/ex01/Makefile b/cpp09/ex01/Makefile index eebe749..8b6e1f2 100644 --- a/cpp09/ex01/Makefile +++ b/cpp09/ex01/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/05/17 14:45:22 by rparodi ### ########.fr # +# Updated: 2025/04/27 18:52:30 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -83,7 +83,7 @@ $(OBJDIRNAME)/%.o: %.cpp @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' @$(CXX) $(CXXFLAGS) -o $@ -c $< -test: re +test: @printf '$(GREY) Testing with $(END)$(GOLD)./RPN ""$(END)\n' @./$(NAME) "" @printf '\n' @@ -109,8 +109,12 @@ test: re @valgrind ./$(NAME) "1 2 * 2 / 2 * 2 4 - +" 2> /tmp/RPN_test @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' + @./$(NAME) "(1 + 1)" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' + @valgrind ./$(NAME) "(1 + 1)" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 -run: test # Header header: @clear diff --git a/cpp09/ex02/Makefile b/cpp09/ex02/Makefile index 443549c..496bedd 100644 --- a/cpp09/ex02/Makefile +++ b/cpp09/ex02/Makefile @@ -88,9 +88,6 @@ debug: re test: debug @./$(NAME) $(shell shuf -i 1-100000 -n 3000 | tr "\n" " ") -run: re - @./$(NAME) $(shell shuf -i 1-100000 -n 3000 | tr "\n" " ") - # Header header: @clear diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bb33fd6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746328495, + "narHash": "sha256-uKCfuDs7ZM3QpCE/jnfubTg459CnKnJG/LwqEVEdEiw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "979daf34c8cacebcd917d540070b52a3c2b9b16e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +}