Teacup rim text: Difference between revisions
C - changed logic to match Rust
m (Minor edit to C code) |
(C - changed logic to match Rust) |
||
Line 119:
}
return result != NULL ? *result : NULL;
}
void find_teacup_words(GPtrArray* dictionary) {
GHashTable* found =
▲ GPtrArray* teacup_words = g_ptr_array_new_full(8, g_free);
GString* temp = g_string_sized_new(8);
for (size_t i = 0, n = dictionary->len; i < n; ++i) {
size_t len = strlen(word);
if (len < 3 || g_hash_table_contains(found, word))
Line 136:
g_ptr_array_set_size(teacup_words, 0);
g_string_assign(temp, word);
bool is_teacup_word = true;
for (size_t i = 0; i < len - 1; ++i) {
rotate(temp->str, len);
if (w == NULL)
is_teacup_word = false;
break;
}
g_ptr_array_add(teacup_words, g_strdup(temp->str));▼
if (strcmp(word, w) != 0 && !g_ptr_array_find(teacup_words, w, NULL))
}
if (is_teacup_word && teacup_words->len
printf("%s", word);
g_hash_table_add(found,
for (size_t i = 0; i <
printf(" %s", teacup_word);
g_hash_table_add(found,
}
printf("\n");
|