diff options
Diffstat (limited to 'src/puzzles/distractions.c')
| -rw-r--r-- | src/puzzles/distractions.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/puzzles/distractions.c b/src/puzzles/distractions.c index bd5db87..c2c57fb 100644 --- a/src/puzzles/distractions.c +++ b/src/puzzles/distractions.c @@ -1,5 +1,6 @@ #include "puzzle.h" #include <raylib.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,12 +19,16 @@ bool isInSignatiureStack(signatureDescriptor *signatures_stack, size_t stack_len size_t signature_len = strlen(signature); for (size_t i = 0; i < stack_len; ++i) { signatureDescriptor *desc = &signatures_stack[i]; - if (!strncmp(reciever, desc->reciever_name, reciever_len)) - return false; - if (!strncmp(signature, desc->method_signature, signature_len)) - return false; + // printf("comparing %s.%s and %s.%s\n", desc->reciever_name, desc->method_signature, + // reciever, signature); + if ( strlen(desc->reciever_name) == reciever_len + && strncmp(reciever, desc->reciever_name, reciever_len) == 0 + && strlen(desc->method_signature) == signature_len + && strncmp(signature, desc->method_signature, signature_len) == 0) + return true; + // printf("Not equal \n"); } - return true; + return false; } // The naive implementation relies on the amount of tests and function overloads @@ -40,7 +45,7 @@ size_t deriveDifficuty(Puzzle *puzzle) { size_t stack_len = 0; for (size_t i = 0; i < puzzle->TestC; ++i) { Test *test = &puzzle->Tests[i]; - if (isInSignatiureStack(signatures_stack, stack_len, + if (!isInSignatiureStack(signatures_stack, stack_len, test->RecieverName, test->MainMethodSignature)) { signatures_stack[stack_len] = (signatureDescriptor) { .reciever_name = test->RecieverName, @@ -49,8 +54,9 @@ size_t deriveDifficuty(Puzzle *puzzle) { stack_len += 1; } } + // printf("stack len: %zu\n", stack_len); free(signatures_stack); - return puzzle->TestC * stack_len + 1; + return puzzle->TestC * stack_len; } DistractionPuzzle *GetRandomDistraction() { |
