From b4f9739ec2824da164cbeb492918506ab260280f Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Sat, 1 Apr 2023 02:22:16 +0200 Subject: [PATCH] Fixes --- ex04/ft_fibonacci.c | 7 +++---- ex08/ft_ten_queens_puzzle.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ex04/ft_fibonacci.c b/ex04/ft_fibonacci.c index 29540e0..a538f40 100644 --- a/ex04/ft_fibonacci.c +++ b/ex04/ft_fibonacci.c @@ -6,13 +6,14 @@ /* By: tosuman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/30 00:36:21 by tosuman #+# #+# */ -/* Updated: 2023/03/30 00:36:22 by tosuman ### ########.fr */ +/* Updated: 2023/04/01 02:20:35 by tischmid ### ########.fr */ /* */ /* ************************************************************************** */ #include #include #define NUM_TYPE int +#define MAX_INDEX 10000 NUM_TYPE memoized_fibonacci(unsigned int index, NUM_TYPE *cache) { @@ -25,12 +26,11 @@ NUM_TYPE memoized_fibonacci(unsigned int index, NUM_TYPE *cache) int ft_fibonacci(int index) { int i; - NUM_TYPE *cache; + NUM_TYPE cache[MAX_INDEX + 1]; NUM_TYPE fibn; if (index < 0) return (-1); - cache = malloc(sizeof(NUM_TYPE) * (index + 1)); cache[0] = 0; cache[1] = 1; i = 2; @@ -38,7 +38,6 @@ int ft_fibonacci(int index) cache[i++] = (NUM_TYPE)(-1); fibn = memoized_fibonacci((unsigned int) index, cache); i = 0; - free(cache); return (fibn); } diff --git a/ex08/ft_ten_queens_puzzle.c b/ex08/ft_ten_queens_puzzle.c index b705509..a7aa980 100644 --- a/ex08/ft_ten_queens_puzzle.c +++ b/ex08/ft_ten_queens_puzzle.c @@ -6,7 +6,7 @@ /* By: tosuman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/30 17:05:04 by tosuman #+# #+# */ -/* Updated: 2023/04/01 02:17:57 by tischmid ### ########.fr */ +/* Updated: 2023/04/01 02:18:59 by tischmid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,7 @@ int is_valid_board(int cols[SIZE], int col) int backtrack(int cols[SIZE], int col) { int i; - int sols; + int sols; if (col >= SIZE) return (new_sol(cols));