shithub: util

Download patch

ref: 30d7ba73ff01b66e88e28faa260583935a20c1d7
parent: 970b9575619b8d39bac6554449ff164d6d5ceef6
author: eli <eli@singularity>
date: Sun May 12 18:27:52 EDT 2024

anagrams update

--- a/anagrams.c
+++ b/anagrams.c
@@ -76,6 +76,11 @@
 			items->children[items->nchildren] = child;
 			items->nchildren++;
 
+			if (contains(child->input, cur->word) == 0) {
+				cur = cur->next;
+				continue;
+			}
+
 			removechars(child->input, cur->word);
 			child->anagram = realloc(child->anagram, strlen(child->anagram) + strlen(cur->word) + 2);
 			sprintf(&child->anagram[strlen(child->anagram)], "%s ", cur->word);
@@ -177,6 +182,11 @@
 		items->children = realloc(items->children, (items->nchildren+1) * sizeof(item*));
 		items->children[items->nchildren] = child;
 		items->nchildren++;
+
+		if (contains(child->input, dict->word) == 0) {
+			dict = dict->next;
+			continue;
+		}
 
 		removechars(child->input, dict->word);
 		child->anagram = realloc(child->anagram, strlen(child->anagram) + strlen(dict->word) + 2);