summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/dlist/dlist-4.c
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
commit73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch)
treee299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/tinyprintf/dlist/dlist-4.c
parentc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff)
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/tinyprintf/dlist/dlist-4.c')
-rw-r--r--rushs/tinyprintf/dlist/dlist-4.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/rushs/tinyprintf/dlist/dlist-4.c b/rushs/tinyprintf/dlist/dlist-4.c
deleted file mode 100644
index 9ed7aaa..0000000
--- a/rushs/tinyprintf/dlist/dlist-4.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "dlist.h"
-
-size_t max(size_t a, size_t b)
-{
- if (a >= b)
- {
- return a;
- }
- return b;
-}
-
-size_t min(size_t a, size_t b)
-{
- if (a <= b)
- {
- return a;
- }
- return b;
-}
-
-size_t min_3(size_t a, size_t b, size_t c)
-{
- if (a <= b)
- {
- if (a <= c)
- {
- return a;
- }
- return c;
- }
- else
- {
- if (b <= c)
- {
- return b;
- }
- return c;
- }
-}
-
-size_t my_strlen(const int *s)
-{
- size_t i;
- for (i = 0; s[i] != -1; i++)
- {
- continue;
- }
- return i;
-}
-
-size_t levenshtein(const int *s1, const int *s2)
-{
- size_t l1 = my_strlen(s1);
- size_t l2 = my_strlen(s2);
- if (min(l1, l2) == 0)
- {
- return max(l1, l2);
- }
-
- if (s1[0] == s2[0])
- {
- return levenshtein(s1 + 1, s2 + 1);
- }
-
- size_t lev1 = levenshtein(s1 + 1, s2);
- size_t lev2 = levenshtein(s1, s2 + 1);
- size_t lev3 = levenshtein(s1 + 1, s2 + 1);
-
- return 1 + min_3(lev1, lev2, lev3);
-}
-
-int *to_str(const struct dlist *l)
-{
- int *res = malloc((l->size + 1) * sizeof(int));
- res[l->size] = -1;
- size_t j = 0;
- for (struct dlist_item *i = l->head; i; i = i->next, j++)
- {
- res[j] = i->data;
- }
- return res;
-}
-
-unsigned int dlist_levenshtein(const struct dlist *list1,
- const struct dlist *list2)
-{
- int *l1 = to_str(list1);
- int *l2 = to_str(list2);
-
- unsigned int res = levenshtein(l1, l2);
- free(l1);
- free(l2);
- return res;
-}