diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07e3236 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +words.c + +WORDLE.gb +*.cdb +*.map +*.noi + diff --git a/Makefile b/Makefile index e5d06bf..4fb0011 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" GBDK_HOME = ../../../ -LCC = $(GBDK_HOME)bin/lcc +LCC = $(GBDK_HOME)bin/lcc -Wa-l -Wl-m -Wl-j # You can uncomment the line below to turn on debug output # LCC = $(LCC) -debug @@ -15,11 +15,14 @@ LCC = $(GBDK_HOME)bin/lcc PROJECTNAME = WORDLE BINS = $(PROJECTNAME).gb -CSOURCES := $(wildcard *.c) +CSOURCES := main.c word-db.c words.c ASMSOURCES := $(wildcard *.s) all: $(BINS) +words.c: wordle_compress/generate_words.py wordle_compress/wordlist_answers.txt wordle_compress/wordlist_guesses.txt + python3 wordle_compress/generate_words.py wordle_compress/wordlist_answers.txt wordle_compress/wordlist_guesses.txt words.c + compile.bat: Makefile @echo "REM Automatically generated from Makefile" > compile.bat @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat diff --git a/bloom.c b/bloom.c deleted file mode 100644 index cdcffeb..0000000 --- a/bloom.c +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include -#include -#include -#include "bloom.h" - -struct bloom_hash { - hash_function func; - struct bloom_hash *next; -}; - - -uint32_t djb2(const char *_str) { - const char *str = _str; - uint32_t hash = 5381; - uint8_t c; - while ((c = *str++)) { - hash = ((hash << 5) + hash) + (uint32_t)c; - } - return hash; -} - -// uint32_t jenkins(const void *_str) { -// const char *key = _str; -// uint32_t hash; -// uint32_t i; -// while (*key) { -// hash += *key; -// hash += (hash << 10); -// hash ^= (hash >> 6); -// key++; -// } -// hash += (hash << 3); -// hash ^= (hash >> 11); -// hash += (hash << 15); -// return hash; -// } - - -bloom_t bloom_create_existing(size_t size, uint8_t *bits) { - bloom_t res = calloc(1, sizeof(struct bloom_filter)); - res->size = size; - res->bits = bits; - return res; -} - -bloom_t bloom_create(size_t size) { - bloom_t res = calloc(1, sizeof(struct bloom_filter)); - res->size = size; - res->bits = malloc(size); - memset(res->bits, 0, size); - return res; -} - -void bloom_free(bloom_t filter) { - if (filter) { - while (filter->func) { - struct bloom_hash *h = filter->func; - filter->func = h->next; - free(h); - } - free(filter->bits); - free(filter); - } -} - -void bloom_add_hash(bloom_t filter, hash_function func) { - struct bloom_hash *h = calloc(1, sizeof(struct bloom_hash)); - h->func = func; - struct bloom_hash *last = filter->func; - while (last && last->next) { - last = last->next; - } - if (last) { - last->next = h; - } else { - filter->func = h; - } -} - -void bloom_add(bloom_t filter, const char *item) { - struct bloom_hash *h = filter->func; - uint8_t *bits = filter->bits; - while (h) { - uint32_t hash = h->func(item); - hash %= filter->size * 8; - bits[hash / 8] |= 1 << hash % 8; - h = h->next; - } -} - -bool bloom_test(bloom_t filter, const char *item) { - struct bloom_hash *h = filter->func; - uint8_t *bits = filter->bits; - while (h) { - uint32_t hash = h->func(item); - hash %= filter->size * 8; - if (!(bits[hash / 8] & 1 << hash % 8)) { - return false; - } - h = h->next; - } - return true; -} diff --git a/bloom.h b/bloom.h deleted file mode 100644 index 7a00c8d..0000000 --- a/bloom.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _BLOOM_H -#define _BLOOM_H -#include -#include -#include - -typedef uint32_t (*hash_function)(const char *data); - - -struct bloom_filter { - struct bloom_hash *func; - uint8_t *bits; - size_t size; -}; -typedef struct bloom_filter * bloom_t; -uint32_t djb2(const char *_str); -uint32_t jenkins(const char *_str); -/* Creates a new bloom filter with no hash functions and size * 8 bits. */ -bloom_t bloom_create(size_t size); -bloom_t bloom_create_existing(size_t size, uint8_t *bits); -/* Frees a bloom filter. */ -void bloom_free(bloom_t filter); -/* Adds a hashing function to the bloom filter. You should add all of the - * functions you intend to use before you add any items. */ -void bloom_add_hash(bloom_t filter, hash_function func); -/* Adds an item to the bloom filter. */ -void bloom_add(bloom_t filter, const char *item); -/* Tests if an item is in the bloom filter. - * - * Returns false if the item has definitely not been added before. Returns true - * if the item was probably added before. */ -bool bloom_test(bloom_t filter, const char *item); - -#endif diff --git a/filter.h b/filter.h deleted file mode 100644 index eaa98f2..0000000 --- a/filter.h +++ /dev/null @@ -1,630 +0,0 @@ -const size_t bloom_data_len = 5000; -uint8_t bloom_data[] = { - 0xD2, 0x01, 0x04, 0x04, 0x00, 0x01, 0x08, 0x15, - 0x42, 0x54, 0x20, 0x28, 0x80, 0x80, 0x2A, 0x00, - 0x10, 0x08, 0x02, 0x80, 0x00, 0x42, 0x20, 0x80, - 0x10, 0x00, 0xC4, 0x50, 0x60, 0x24, 0xB0, 0x20, - 0x02, 0x06, 0x00, 0x40, 0x40, 0x40, 0x02, 0x10, - 0x24, 0x00, 0x1E, 0x10, 0x02, 0x18, 0x3E, 0x03, - 0x09, 0x20, 0x00, 0x68, 0x10, 0x38, 0x30, 0x02, - 0x00, 0x18, 0x00, 0x4C, 0x04, 0x40, 0x00, 0x10, - 0x08, 0x44, 0x02, 0x10, 0x84, 0x00, 0x00, 0x02, - 0x80, 0xA0, 0x00, 0x08, 0x80, 0x20, 0x88, 0x80, - 0x01, 0xB0, 0x12, 0x20, 0x00, 0x10, 0x04, 0xB0, - 0x00, 0x00, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x41, 0xC9, 0x00, 0x50, 0x50, 0x04, 0x01, - 0x00, 0x03, 0x80, 0x00, 0x08, 0x40, 0x00, 0x00, - 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x04, 0x47, - 0x02, 0x00, 0x91, 0x00, 0x04, 0x30, 0x00, 0x00, - 0x18, 0x20, 0x88, 0xDD, 0x08, 0x10, 0x44, 0x02, - 0x00, 0x20, 0x29, 0x90, 0x10, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x40, 0x00, 0x81, 0x18, 0x22, 0x02, - 0x30, 0x10, 0x94, 0x94, 0x05, 0x23, 0x45, 0x83, - 0x00, 0x00, 0x02, 0x18, 0x44, 0x00, 0xE0, 0x00, - 0x40, 0x10, 0x01, 0x02, 0x82, 0x08, 0x08, 0x40, - 0x00, 0x44, 0x00, 0xC8, 0x80, 0x21, 0x25, 0x02, - 0x00, 0x40, 0x74, 0x01, 0xC0, 0x20, 0x80, 0x10, - 0x01, 0x04, 0x31, 0x80, 0x20, 0x0C, 0x08, 0x80, - 0x04, 0x02, 0x10, 0x46, 0x84, 0x03, 0x08, 0x00, - 0x82, 0x00, 0x88, 0x00, 0xA8, 0x88, 0x28, 0x12, - 0x19, 0x80, 0x84, 0x64, 0x00, 0x08, 0x00, 0x0C, - 0x40, 0x00, 0xC3, 0x00, 0x01, 0x01, 0x01, 0x14, - 0x00, 0x00, 0x04, 0x40, 0x10, 0x04, 0x00, 0x62, - 0x10, 0x00, 0x00, 0x05, 0x00, 0x01, 0x00, 0x80, - 0xC0, 0x10, 0x90, 0x09, 0xC4, 0x8C, 0x44, 0x02, - 0x9D, 0x00, 0x08, 0x00, 0x00, 0x9C, 0x00, 0x80, - 0x18, 0x30, 0x02, 0x10, 0x00, 0x00, 0x80, 0x40, - 0x60, 0x00, 0x10, 0x40, 0x08, 0x60, 0x01, 0x04, - 0x84, 0x00, 0x10, 0x80, 0x00, 0x88, 0x08, 0x12, - 0xC8, 0x04, 0x40, 0x00, 0x00, 0x00, 0x50, 0x00, - 0x00, 0x01, 0x08, 0x01, 0x0F, 0xA1, 0x02, 0x00, - 0x01, 0x20, 0x06, 0x40, 0x03, 0x01, 0x10, 0x20, - 0x04, 0x00, 0x46, 0x00, 0x82, 0x60, 0x01, 0x85, - 0x04, 0x40, 0x34, 0x80, 0x21, 0x18, 0x40, 0x10, - 0x40, 0x0C, 0x10, 0x80, 0x80, 0x28, 0x00, 0x62, - 0x80, 0x10, 0x00, 0x80, 0x14, 0x04, 0x08, 0x50, - 0x04, 0x09, 0x11, 0x00, 0x04, 0x02, 0x06, 0x20, - 0x10, 0x1A, 0xB1, 0x00, 0x04, 0x00, 0x64, 0x40, - 0x00, 0x00, 0x91, 0x2D, 0x25, 0x20, 0x6C, 0x50, - 0x20, 0x05, 0x80, 0x60, 0xC7, 0x14, 0x05, 0x00, - 0x88, 0x20, 0x80, 0x48, 0x00, 0x01, 0x70, 0x22, - 0x91, 0x91, 0x00, 0x00, 0xA0, 0x46, 0x03, 0x88, - 0x08, 0x00, 0x46, 0x00, 0x19, 0xCD, 0x00, 0x01, - 0x80, 0x10, 0x50, 0x80, 0x40, 0x00, 0x08, 0x80, - 0x00, 0xD0, 0xD0, 0x13, 0x20, 0x80, 0x00, 0x00, - 0x00, 0x40, 0x10, 0x03, 0x88, 0x00, 0x00, 0x00, - 0x40, 0x14, 0x40, 0xD4, 0x50, 0x40, 0x00, 0x00, - 0x25, 0x44, 0x02, 0x23, 0x02, 0xA0, 0x10, 0x20, - 0x09, 0x00, 0x24, 0x81, 0x44, 0x00, 0x00, 0xAC, - 0x01, 0x04, 0xD4, 0x10, 0xD6, 0x05, 0xC0, 0x20, - 0x40, 0x0C, 0x20, 0xC8, 0x0A, 0x04, 0x00, 0x02, - 0x81, 0x28, 0x06, 0x00, 0x60, 0x80, 0x04, 0x00, - 0x08, 0x40, 0x00, 0x00, 0x04, 0x11, 0x00, 0x22, - 0x40, 0x21, 0x5A, 0x88, 0x00, 0x0B, 0x00, 0x40, - 0x81, 0x08, 0x00, 0x80, 0x10, 0x14, 0x45, 0xA1, - 0x23, 0x00, 0x00, 0x44, 0x00, 0x02, 0xAA, 0x20, - 0xA8, 0x18, 0x01, 0x00, 0x40, 0x04, 0xD2, 0x01, - 0x10, 0x02, 0x03, 0x08, 0x08, 0x20, 0x46, 0x01, - 0x09, 0xA8, 0xA0, 0x40, 0x1A, 0x80, 0x40, 0x08, - 0x02, 0x14, 0x01, 0x40, 0x26, 0x80, 0x08, 0x02, - 0xE0, 0x04, 0x22, 0x1C, 0x02, 0xDC, 0x01, 0x18, - 0x02, 0x40, 0x28, 0x49, 0x02, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x10, 0x40, 0x64, 0x03, 0xA4, - 0x28, 0x01, 0x04, 0x02, 0x12, 0x54, 0x88, 0x40, - 0x02, 0x04, 0x5C, 0x06, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x44, 0x28, 0x05, 0x1C, 0x28, 0x04, - 0x0E, 0x45, 0xD3, 0x61, 0x5C, 0x26, 0x08, 0x00, - 0x30, 0x44, 0x18, 0x01, 0x00, 0x11, 0x04, 0x44, - 0x80, 0x01, 0x26, 0xB8, 0x41, 0x10, 0xA0, 0x08, - 0xD0, 0x02, 0xA4, 0x21, 0x41, 0x00, 0x40, 0x04, - 0x85, 0x84, 0x44, 0x40, 0x00, 0x80, 0x80, 0x04, - 0x00, 0x03, 0x10, 0x80, 0x15, 0x00, 0x04, 0x81, - 0x56, 0x10, 0x8E, 0x00, 0xC0, 0x28, 0x80, 0x40, - 0x2A, 0x09, 0x08, 0x03, 0x04, 0x01, 0x22, 0x20, - 0x08, 0x50, 0x26, 0xE8, 0x04, 0x70, 0x80, 0xD0, - 0xC1, 0x05, 0x02, 0x88, 0x03, 0x00, 0x48, 0x08, - 0x02, 0x11, 0x01, 0x98, 0x4C, 0x40, 0x2A, 0x00, - 0x00, 0x00, 0x00, 0x03, 0xA0, 0x00, 0x20, 0x0A, - 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x14, 0x22, - 0x80, 0x00, 0x00, 0x20, 0x10, 0x08, 0x21, 0x01, - 0x01, 0x04, 0x00, 0x01, 0xC0, 0x10, 0x00, 0x94, - 0x00, 0x07, 0x70, 0x14, 0x49, 0x84, 0xC0, 0x08, - 0x04, 0x00, 0x00, 0x09, 0x20, 0x01, 0x04, 0x80, - 0x00, 0x04, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x44, 0x80, 0x08, 0x48, 0x21, 0x0B, 0x00, - 0x00, 0x41, 0x24, 0x00, 0x06, 0x70, 0x00, 0x00, - 0x10, 0x84, 0x14, 0x08, 0x0C, 0x00, 0x82, 0x00, - 0x00, 0x41, 0x10, 0x81, 0x80, 0x32, 0x00, 0x28, - 0x08, 0xAC, 0xDC, 0x0D, 0x04, 0xC1, 0x08, 0x0A, - 0x80, 0x51, 0x8F, 0xB9, 0x02, 0xE2, 0x08, 0x20, - 0x10, 0x00, 0x00, 0xA0, 0x08, 0x60, 0x10, 0x00, - 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x24, - 0x08, 0x01, 0x84, 0x00, 0x0B, 0x88, 0x01, 0x00, - 0x02, 0x01, 0x10, 0x04, 0x00, 0x20, 0x20, 0x00, - 0x59, 0x02, 0x00, 0x20, 0x90, 0x00, 0x80, 0x00, - 0x00, 0x08, 0x30, 0x0A, 0x44, 0x10, 0x40, 0x0A, - 0x80, 0x0B, 0x10, 0x90, 0x0A, 0x00, 0x00, 0x04, - 0x10, 0x40, 0x00, 0x08, 0xE1, 0x03, 0x80, 0x80, - 0x90, 0x2B, 0x40, 0x92, 0x41, 0x10, 0x09, 0x04, - 0x11, 0x00, 0x20, 0x00, 0x80, 0x12, 0x01, 0x4C, - 0x18, 0x00, 0x10, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x4A, 0x4C, 0xA0, 0x86, 0x00, 0x10, 0x45, 0x4C, - 0x48, 0x00, 0x61, 0x44, 0x88, 0x04, 0x80, 0x08, - 0x90, 0x02, 0x85, 0x20, 0x9A, 0x25, 0x04, 0x5C, - 0x03, 0x00, 0x02, 0x14, 0x40, 0x2E, 0x58, 0x00, - 0x00, 0x80, 0x81, 0x80, 0x3C, 0x45, 0x40, 0x86, - 0x14, 0x21, 0x20, 0x00, 0x14, 0x14, 0x01, 0x40, - 0x8A, 0x00, 0x01, 0x40, 0xC0, 0x80, 0xDB, 0x51, - 0x01, 0x04, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x20, 0x20, 0x80, 0x01, 0x94, 0x04, 0x88, - 0x00, 0xA4, 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, - 0x44, 0x02, 0x40, 0x00, 0x02, 0x00, 0x81, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x04, - 0x00, 0x40, 0x20, 0x00, 0x10, 0x00, 0x40, 0x04, - 0x10, 0x81, 0x00, 0x00, 0x28, 0x00, 0x10, 0x20, - 0x34, 0x04, 0x08, 0x00, 0x48, 0x00, 0x02, 0x20, - 0x02, 0x00, 0x00, 0x02, 0x00, 0x08, 0x02, 0x00, - 0x00, 0x28, 0x06, 0x08, 0x10, 0x00, 0x09, 0x04, - 0x98, 0x04, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, - 0x10, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x40, - 0x00, 0x38, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x48, 0xA0, 0x16, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x20, 0x0A, 0x01, 0x82, 0x01, 0x81, - 0x00, 0x11, 0x41, 0x20, 0x43, 0x01, 0x00, 0x84, - 0x20, 0x00, 0x08, 0x10, 0x88, 0x18, 0x24, 0x39, - 0x00, 0x41, 0x00, 0x00, 0x40, 0x40, 0x08, 0x10, - 0x04, 0x80, 0x40, 0x94, 0x00, 0x01, 0x00, 0x55, - 0x00, 0x02, 0x80, 0x00, 0x81, 0x00, 0x20, 0x20, - 0x08, 0x80, 0x24, 0x00, 0x00, 0x02, 0x02, 0x0A, - 0x00, 0x00, 0x20, 0x00, 0xC0, 0x01, 0x80, 0x0A, - 0x20, 0x00, 0x80, 0x34, 0x04, 0x00, 0x08, 0x40, - 0x10, 0x00, 0x00, 0x03, 0x01, 0x08, 0x68, 0x00, - 0x10, 0x00, 0x0C, 0x02, 0x02, 0x00, 0x88, 0x00, - 0xB0, 0x00, 0x09, 0x12, 0x80, 0x83, 0x08, 0x28, - 0x81, 0x20, 0x28, 0x10, 0x00, 0x08, 0x00, 0x88, - 0x11, 0x40, 0xD4, 0x46, 0x00, 0x20, 0x02, 0x28, - 0x08, 0xEC, 0x01, 0x12, 0x00, 0x08, 0x20, 0x04, - 0x41, 0x40, 0x45, 0x0C, 0x06, 0x01, 0x09, 0x0C, - 0x0A, 0x0C, 0x80, 0x20, 0x00, 0x27, 0x09, 0x04, - 0x82, 0x88, 0x40, 0x00, 0x80, 0x24, 0x40, 0x09, - 0x00, 0x58, 0x02, 0x40, 0x02, 0x18, 0xC2, 0x00, - 0x50, 0x10, 0x08, 0x71, 0x04, 0x60, 0x01, 0x20, - 0x0E, 0x88, 0x01, 0x02, 0x80, 0x02, 0x11, 0x21, - 0x80, 0x08, 0x00, 0x40, 0x02, 0x00, 0x02, 0x00, - 0x80, 0x88, 0x0C, 0x18, 0x08, 0x00, 0x28, 0xC1, - 0x00, 0x00, 0x00, 0xA8, 0x01, 0x60, 0x10, 0x10, - 0x00, 0x04, 0x08, 0x00, 0x60, 0x80, 0x00, 0x02, - 0x00, 0x02, 0x09, 0x00, 0x80, 0x00, 0x62, 0x00, - 0x80, 0x00, 0x0C, 0x00, 0x03, 0x88, 0x02, 0xC0, - 0x44, 0x01, 0x44, 0x02, 0x8A, 0x42, 0x04, 0x0A, - 0x03, 0x80, 0x09, 0x10, 0x20, 0xD9, 0x00, 0x20, - 0x02, 0x41, 0x10, 0x00, 0x10, 0x00, 0x00, 0x80, - 0x00, 0x80, 0x10, 0x44, 0x60, 0x01, 0x80, 0x00, - 0x10, 0x00, 0x08, 0x05, 0x00, 0x08, 0xC4, 0x42, - 0x08, 0x41, 0x00, 0x01, 0x0C, 0x25, 0x00, 0x04, - 0x51, 0x48, 0x80, 0x28, 0x22, 0x80, 0x20, 0x60, - 0x00, 0x50, 0x4D, 0x40, 0x48, 0x00, 0x02, 0x11, - 0x18, 0x41, 0x00, 0x14, 0x00, 0x20, 0x00, 0x2A, - 0x50, 0x11, 0x44, 0x0B, 0x40, 0x03, 0x90, 0x00, - 0x1D, 0x42, 0x4D, 0x00, 0x20, 0xC0, 0x08, 0x05, - 0x00, 0xD6, 0xC0, 0x23, 0x80, 0x02, 0x80, 0x22, - 0x00, 0x00, 0x00, 0x30, 0x12, 0x49, 0x00, 0x08, - 0x80, 0x01, 0xE4, 0x41, 0x02, 0x80, 0xC0, 0x40, - 0x00, 0x18, 0x10, 0x41, 0x60, 0x94, 0x02, 0x01, - 0x22, 0x0A, 0x40, 0x80, 0x11, 0x62, 0xC0, 0x20, - 0x84, 0x48, 0x50, 0x04, 0x51, 0x00, 0x0C, 0xC0, - 0x04, 0x05, 0x48, 0x04, 0xC0, 0x60, 0x1C, 0x05, - 0xC2, 0x00, 0x22, 0x80, 0x00, 0x01, 0x08, 0x10, - 0x44, 0x41, 0xC1, 0x20, 0x51, 0x44, 0x55, 0x41, - 0x41, 0x02, 0x96, 0x27, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x22, 0xA0, 0x0E, 0x22, 0x84, 0x10, 0x00, - 0x01, 0x88, 0x1C, 0x47, 0x20, 0x00, 0x48, 0x44, - 0x0D, 0x0F, 0x00, 0xA8, 0x00, 0x01, 0x26, 0x01, - 0x64, 0x03, 0x12, 0xE4, 0x08, 0x04, 0x91, 0x92, - 0x14, 0x1A, 0x0E, 0x40, 0xCC, 0x62, 0x4A, 0x0A, - 0x80, 0x41, 0xA4, 0x00, 0xB8, 0x26, 0x0C, 0x3B, - 0xE6, 0x80, 0xA5, 0x52, 0xD0, 0x90, 0x02, 0x54, - 0x00, 0x50, 0x00, 0x20, 0x00, 0x52, 0x02, 0x00, - 0x05, 0x11, 0x00, 0x04, 0x00, 0x03, 0x00, 0x02, - 0x16, 0x62, 0xA0, 0x09, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x61, 0x06, 0x44, 0x00, 0x10, - 0x00, 0xE4, 0x0D, 0xA0, 0x00, 0x0E, 0x59, 0x04, - 0x15, 0x00, 0x10, 0x92, 0xC5, 0x64, 0x18, 0x00, - 0x28, 0x82, 0x4C, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x30, 0x25, 0xCC, 0x21, 0x02, 0x08, 0x00, 0x00, - 0x20, 0x50, 0x02, 0x60, 0x30, 0x29, 0x63, 0x6C, - 0xD0, 0x9A, 0x0D, 0x14, 0xC0, 0x28, 0x00, 0x00, - 0x40, 0x08, 0xBA, 0x00, 0x80, 0x10, 0x01, 0x02, - 0x08, 0x05, 0x1E, 0x10, 0x40, 0x09, 0x00, 0x00, - 0x01, 0x58, 0x04, 0x02, 0x50, 0x00, 0x34, 0x00, - 0x92, 0x20, 0x28, 0x02, 0x01, 0x02, 0x70, 0x00, - 0x30, 0x80, 0x10, 0x10, 0x24, 0x08, 0x89, 0x00, - 0x80, 0x80, 0x22, 0x00, 0x00, 0x03, 0x80, 0xA1, - 0x20, 0x82, 0x02, 0x90, 0x12, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x90, 0x00, 0x08, 0x11, 0x06, 0xCC, - 0x00, 0x00, 0x02, 0x00, 0x08, 0x10, 0x00, 0x46, - 0x24, 0x20, 0x10, 0x8F, 0x00, 0x20, 0x20, 0x02, - 0x00, 0x00, 0x00, 0x44, 0x80, 0x42, 0x02, 0x01, - 0x22, 0x80, 0x10, 0x04, 0x08, 0x00, 0x20, 0x00, - 0x38, 0x0A, 0x08, 0x50, 0x90, 0x2C, 0x31, 0x49, - 0x21, 0x01, 0xC0, 0x30, 0x0A, 0x10, 0x04, 0x00, - 0x04, 0x00, 0x45, 0x20, 0x59, 0x8F, 0x73, 0xF0, - 0x05, 0x60, 0x4A, 0x80, 0x0A, 0x02, 0x40, 0x08, - 0x32, 0x00, 0x00, 0x10, 0x37, 0x52, 0x26, 0x4C, - 0x40, 0x65, 0xC6, 0x50, 0x13, 0x18, 0x10, 0x00, - 0x20, 0x30, 0x3A, 0x63, 0x40, 0x10, 0x22, 0x23, - 0x00, 0x11, 0xE4, 0xC4, 0x05, 0x30, 0x11, 0x29, - 0x72, 0x0B, 0x50, 0x02, 0x05, 0xC0, 0x05, 0x20, - 0x89, 0x04, 0x51, 0x04, 0x40, 0x04, 0x11, 0x89, - 0x64, 0x80, 0xC8, 0x01, 0x01, 0x14, 0x10, 0x01, - 0x62, 0x91, 0x28, 0x03, 0x00, 0x0D, 0x02, 0x84, - 0x09, 0x10, 0x10, 0x84, 0x00, 0x5C, 0x00, 0x03, - 0x21, 0x80, 0x01, 0x00, 0x40, 0x20, 0x10, 0x00, - 0x04, 0x28, 0x82, 0x38, 0x00, 0x00, 0x81, 0x00, - 0x11, 0x01, 0xA0, 0x0E, 0x20, 0x00, 0x00, 0x00, - 0x0C, 0x00, 0xA1, 0x70, 0x40, 0x48, 0x00, 0x84, - 0x61, 0x01, 0x00, 0x14, 0x10, 0x88, 0x08, 0x40, - 0x04, 0x10, 0x4C, 0xD8, 0x86, 0x3E, 0x00, 0x48, - 0x00, 0x10, 0x00, 0x00, 0x20, 0x90, 0x00, 0x41, - 0x10, 0x23, 0x44, 0x2A, 0x80, 0x68, 0x40, 0x4A, - 0xAC, 0x03, 0x80, 0x10, 0x01, 0x00, 0x04, 0x20, - 0x14, 0x02, 0x00, 0x00, 0x80, 0x13, 0x00, 0x17, - 0x00, 0x44, 0x87, 0x08, 0x8A, 0x20, 0x02, 0x0B, - 0x04, 0x03, 0x00, 0x2A, 0x00, 0x29, 0x00, 0x60, - 0x46, 0x90, 0x42, 0x88, 0x30, 0x08, 0x46, 0x01, - 0x02, 0x00, 0x02, 0x00, 0xA0, 0x88, 0x08, 0x05, - 0x88, 0x29, 0x08, 0x20, 0x22, 0x18, 0x60, 0x01, - 0x34, 0x03, 0x41, 0x10, 0x12, 0x44, 0x08, 0x18, - 0x04, 0x00, 0x32, 0x21, 0x00, 0xC8, 0x00, 0x80, - 0x00, 0x00, 0x1B, 0x80, 0x00, 0x40, 0x00, 0x80, - 0x04, 0x00, 0x00, 0x20, 0x08, 0x82, 0x01, 0x02, - 0x00, 0x40, 0x02, 0x08, 0x00, 0x04, 0x80, 0x00, - 0x06, 0x00, 0x83, 0x00, 0x08, 0x00, 0xB0, 0x80, - 0x43, 0x00, 0x00, 0x00, 0x02, 0x24, 0x08, 0x01, - 0x80, 0x01, 0x00, 0x80, 0x08, 0x00, 0x04, 0x00, - 0x00, 0x23, 0x20, 0x85, 0xC0, 0x62, 0x00, 0x10, - 0x00, 0xA0, 0x89, 0x44, 0x46, 0x40, 0x05, 0x40, - 0x08, 0x00, 0x20, 0x61, 0x05, 0x10, 0x02, 0x45, - 0x65, 0x09, 0x0A, 0x00, 0x35, 0x14, 0x91, 0x02, - 0x95, 0xE5, 0x08, 0x30, 0x02, 0x00, 0x80, 0x00, - 0x88, 0x42, 0x28, 0x84, 0x18, 0x53, 0xC1, 0x02, - 0x08, 0x04, 0x10, 0xC2, 0x80, 0x00, 0x03, 0x2B, - 0x03, 0x88, 0x80, 0x40, 0x86, 0x01, 0x00, 0x4B, - 0x10, 0x60, 0x10, 0x20, 0x88, 0x70, 0x40, 0x28, - 0xC8, 0x00, 0x81, 0x26, 0x01, 0x3C, 0x09, 0x45, - 0x48, 0xB1, 0x86, 0x60, 0x18, 0x20, 0x0C, 0x40, - 0x08, 0x60, 0x10, 0x00, 0x9C, 0x23, 0x12, 0xA4, - 0x04, 0x80, 0x00, 0xA4, 0x30, 0x30, 0x02, 0x40, - 0x04, 0x00, 0x00, 0x88, 0x09, 0x81, 0x00, 0xA4, - 0x00, 0x0A, 0x80, 0x00, 0x08, 0x40, 0x00, 0x04, - 0x28, 0x00, 0xC8, 0x01, 0x38, 0x19, 0x21, 0x91, - 0x30, 0x18, 0x34, 0x00, 0x1C, 0x24, 0x09, 0x00, - 0x02, 0x01, 0x61, 0xC2, 0x82, 0xA0, 0x00, 0x22, - 0x00, 0x00, 0x11, 0x48, 0x10, 0x01, 0x00, 0xC0, - 0x00, 0x01, 0x00, 0x00, 0x31, 0x04, 0x35, 0xA1, - 0x30, 0x08, 0x20, 0x00, 0x00, 0xA8, 0x50, 0x9B, - 0x78, 0x1C, 0x00, 0x02, 0x01, 0x10, 0x49, 0x15, - 0x61, 0xC4, 0x50, 0x80, 0x10, 0x08, 0xC2, 0x41, - 0x23, 0x01, 0x08, 0x84, 0x40, 0x00, 0x14, 0x80, - 0x02, 0x82, 0x1D, 0x0C, 0x48, 0x80, 0x12, 0x48, - 0x08, 0x00, 0x00, 0x00, 0xA8, 0x01, 0x00, 0x04, - 0x00, 0x82, 0x41, 0xCC, 0xF1, 0x60, 0x84, 0xE3, - 0x11, 0x20, 0x10, 0x00, 0x20, 0x30, 0x00, 0x06, - 0x09, 0x00, 0x00, 0x01, 0x20, 0xC1, 0x20, 0x00, - 0x00, 0x80, 0x00, 0x11, 0x44, 0x08, 0x00, 0x04, - 0x00, 0x00, 0x88, 0x48, 0x16, 0xB1, 0x01, 0x02, - 0x00, 0x00, 0xB2, 0x58, 0x00, 0x4C, 0x48, 0x00, - 0x08, 0xC0, 0x01, 0x46, 0x00, 0x12, 0x10, 0x04, - 0x00, 0x50, 0x0C, 0x08, 0x00, 0x00, 0x18, 0x02, - 0x81, 0x20, 0x40, 0x44, 0x05, 0x00, 0x20, 0x04, - 0x00, 0x11, 0xA5, 0xA0, 0x10, 0x00, 0x12, 0x04, - 0x21, 0x9D, 0x5D, 0xEA, 0x3A, 0x50, 0x20, 0x41, - 0x80, 0x09, 0x60, 0x31, 0x18, 0x00, 0x48, 0xC0, - 0x41, 0x20, 0x30, 0x74, 0x0A, 0x09, 0x28, 0x62, - 0xB0, 0x54, 0x49, 0x24, 0x10, 0xE0, 0x02, 0x00, - 0x00, 0x10, 0x00, 0x08, 0x00, 0x02, 0x50, 0x00, - 0x00, 0x00, 0x1A, 0x01, 0x10, 0x31, 0x68, 0x08, - 0x08, 0x31, 0x11, 0x04, 0x00, 0x00, 0x60, 0x24, - 0x08, 0x00, 0xC0, 0x28, 0x01, 0x40, 0x20, 0xB0, - 0x38, 0x00, 0xB0, 0x80, 0x18, 0x00, 0xC4, 0x03, - 0x09, 0x30, 0x04, 0x00, 0x00, 0x01, 0x30, 0x18, - 0x10, 0x10, 0x43, 0x42, 0x60, 0x40, 0x42, 0x68, - 0x14, 0x01, 0x02, 0x10, 0x20, 0x00, 0x00, 0x10, - 0x48, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x98, - 0x40, 0x80, 0x20, 0x21, 0x50, 0x28, 0x40, 0x08, - 0x00, 0x80, 0x82, 0x81, 0x64, 0x00, 0x44, 0x08, - 0x01, 0x30, 0x0C, 0x08, 0x0B, 0x0C, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x8A, 0x20, 0x00, 0x06, 0x05, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x00, 0x02, - 0x88, 0x53, 0x02, 0xCC, 0x20, 0x50, 0x2A, 0x80, - 0x18, 0x82, 0x02, 0x40, 0x38, 0x03, 0x20, 0xD3, - 0x81, 0xB0, 0x38, 0x00, 0x88, 0x0C, 0x00, 0x06, - 0x05, 0x41, 0x00, 0x00, 0x20, 0x01, 0x80, 0x15, - 0x20, 0x40, 0x00, 0x30, 0x04, 0x00, 0x01, 0x02, - 0x00, 0x54, 0x01, 0x90, 0x41, 0x10, 0xA6, 0x10, - 0x20, 0xC0, 0x48, 0x02, 0x80, 0x00, 0x00, 0x20, - 0x88, 0x00, 0xC0, 0x00, 0x81, 0x00, 0x08, 0x18, - 0x88, 0x00, 0xC1, 0x04, 0x02, 0x00, 0x24, 0x31, - 0x01, 0x92, 0x01, 0x00, 0x83, 0x00, 0x80, 0x41, - 0xD8, 0x04, 0x04, 0x00, 0x00, 0x40, 0x0C, 0x00, - 0x00, 0x60, 0x00, 0x83, 0xA2, 0x09, 0x90, 0x01, - 0x00, 0x20, 0x00, 0x10, 0xC4, 0x00, 0xA0, 0x20, - 0x22, 0xF2, 0x0C, 0x00, 0x00, 0x10, 0x84, 0x50, - 0x00, 0x44, 0x09, 0x01, 0x50, 0xB0, 0xA1, 0x80, - 0x03, 0x31, 0x08, 0x00, 0x00, 0x01, 0x48, 0x10, - 0x09, 0x00, 0x64, 0x27, 0x06, 0x4D, 0x80, 0x50, - 0x04, 0x9C, 0x10, 0x8A, 0x1C, 0x01, 0x00, 0x00, - 0x08, 0xA0, 0x00, 0x10, 0x64, 0x08, 0xC0, 0x04, - 0x40, 0x20, 0xA0, 0x12, 0xA0, 0xEC, 0x89, 0x21, - 0x01, 0x02, 0x02, 0x41, 0x24, 0xE0, 0x10, 0x01, - 0x08, 0x00, 0x10, 0x04, 0x42, 0x02, 0x02, 0x82, - 0x01, 0x28, 0x00, 0x00, 0x14, 0x01, 0x43, 0x04, - 0x05, 0x03, 0xC0, 0x48, 0x82, 0x00, 0x03, 0x10, - 0x00, 0x00, 0x80, 0xC0, 0x00, 0x02, 0x40, 0x20, - 0x0C, 0x04, 0x12, 0x03, 0x00, 0x89, 0xB5, 0x29, - 0x03, 0x00, 0x02, 0x24, 0x00, 0x13, 0x3A, 0x31, - 0x04, 0x00, 0x00, 0x08, 0x12, 0x2C, 0x24, 0x87, - 0x01, 0x42, 0x02, 0x00, 0x00, 0x01, 0x04, 0x00, - 0x01, 0x40, 0x82, 0x00, 0x02, 0xA5, 0x81, 0x00, - 0x9E, 0x02, 0x56, 0x04, 0xC0, 0x25, 0x38, 0x01, - 0x00, 0x20, 0x04, 0x28, 0x11, 0x21, 0x08, 0x02, - 0xC4, 0x00, 0x11, 0x19, 0xC6, 0x31, 0x20, 0x81, - 0x00, 0x01, 0x00, 0x9E, 0x96, 0x21, 0x81, 0xA2, - 0x30, 0x20, 0x0A, 0x00, 0x00, 0x0C, 0x00, 0x16, - 0xD8, 0x00, 0x06, 0x15, 0x10, 0x02, 0x06, 0xD2, - 0xCB, 0x41, 0x09, 0x88, 0x00, 0x01, 0x00, 0x04, - 0xC5, 0xE6, 0x81, 0x08, 0x00, 0x92, 0x12, 0x84, - 0x01, 0x08, 0x04, 0x00, 0x24, 0x08, 0x04, 0x03, - 0xA0, 0x00, 0x01, 0x82, 0x02, 0x00, 0x00, 0x02, - 0x12, 0x70, 0x86, 0x02, 0x8C, 0x43, 0x80, 0x00, - 0x08, 0x80, 0x01, 0x90, 0x11, 0xAC, 0x02, 0x00, - 0x00, 0x10, 0x21, 0x03, 0x01, 0x40, 0x40, 0x80, - 0x90, 0x40, 0x90, 0x65, 0x08, 0x25, 0x10, 0x02, - 0x00, 0x08, 0x00, 0xC4, 0x40, 0x00, 0x40, 0x00, - 0x20, 0x00, 0x20, 0x01, 0xC1, 0x0A, 0x18, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x88, 0x1E, - 0x00, 0x0A, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x06, 0x08, 0x01, 0x00, 0x62, - 0x04, 0x05, 0x20, 0x00, 0x00, 0x40, 0x40, 0x14, - 0x14, 0x21, 0x02, 0xA8, 0xAA, 0x90, 0x09, 0x00, - 0x01, 0x08, 0x64, 0x80, 0x00, 0x0A, 0x80, 0x00, - 0x00, 0x14, 0x00, 0x23, 0x03, 0x00, 0x10, 0x80, - 0x20, 0x84, 0x14, 0x01, 0x20, 0xC0, 0x20, 0x00, - 0x48, 0x27, 0x10, 0x41, 0x02, 0x00, 0x00, 0x00, - 0x11, 0x44, 0x18, 0x23, 0x82, 0x21, 0x62, 0x00, - 0x01, 0x12, 0x41, 0x00, 0x01, 0x21, 0x22, 0x80, - 0x01, 0x00, 0x41, 0x0A, 0x05, 0x02, 0x00, 0x40, - 0x00, 0x04, 0x00, 0x40, 0x20, 0x80, 0x00, 0x08, - 0x08, 0x40, 0x80, 0x00, 0x00, 0x00, 0x20, 0x0C, - 0x80, 0x00, 0x68, 0x00, 0x00, 0x01, 0x24, 0x44, - 0x0C, 0x20, 0xA3, 0x5C, 0x04, 0x02, 0x00, 0x40, - 0x80, 0x00, 0xA0, 0x04, 0x40, 0x90, 0x24, 0x40, - 0x04, 0x00, 0x71, 0x20, 0x41, 0x04, 0x10, 0x30, - 0x00, 0x00, 0x01, 0x00, 0x40, 0x00, 0x00, 0x40, - 0x02, 0x49, 0x04, 0x04, 0x00, 0x10, 0x08, 0x70, - 0x42, 0x84, 0xA8, 0x20, 0x03, 0x00, 0x20, 0x02, - 0x03, 0x42, 0x0E, 0x08, 0x0A, 0x00, 0x00, 0x11, - 0x60, 0x40, 0x40, 0x00, 0x01, 0x30, 0x04, 0xA0, - 0x85, 0x80, 0x58, 0xD0, 0x80, 0x01, 0x40, 0x00, - 0x10, 0x40, 0x00, 0x00, 0x80, 0xAC, 0xC5, 0x3A, - 0x20, 0x44, 0xC0, 0x70, 0x60, 0x30, 0x00, 0x88, - 0x0C, 0x90, 0x02, 0x92, 0x82, 0x31, 0x08, 0x04, - 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xD4, 0xA0, 0xC1, 0x18, 0x23, 0x0A, 0x08, 0x04, - 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x40, - 0x00, 0x21, 0x12, 0x20, 0x85, 0x0C, 0x20, 0x00, - 0x4A, 0x00, 0x00, 0x02, 0xFC, 0x08, 0x80, 0x10, - 0x00, 0x00, 0x40, 0x28, 0x80, 0x01, 0x10, 0x42, - 0x08, 0x05, 0x02, 0x81, 0x84, 0x20, 0x80, 0xC2, - 0x82, 0x00, 0x22, 0x40, 0x20, 0x24, 0x80, 0x4A, - 0x42, 0xC9, 0x0C, 0x10, 0x01, 0x44, 0x10, 0x00, - 0x84, 0x40, 0x09, 0x04, 0x60, 0x00, 0x60, 0x00, - 0x20, 0x23, 0x8C, 0x00, 0x00, 0x00, 0x84, 0x11, - 0x00, 0x10, 0x01, 0x08, 0x22, 0x00, 0x80, 0x90, - 0x00, 0x06, 0xA0, 0x51, 0x08, 0x05, 0x00, 0x02, - 0x88, 0x21, 0x50, 0x10, 0x00, 0x04, 0x00, 0x40, - 0x80, 0x00, 0x42, 0x20, 0x84, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x14, 0x40, 0x00, 0x50, 0x00, - 0x94, 0x00, 0x04, 0x00, 0x02, 0x21, 0x88, 0x04, - 0x00, 0x80, 0x60, 0x00, 0x0C, 0x37, 0x00, 0x05, - 0x02, 0x04, 0x06, 0x02, 0x00, 0x51, 0x00, 0x64, - 0x21, 0x09, 0x00, 0x24, 0x00, 0x44, 0x02, 0x50, - 0x00, 0x00, 0x60, 0x80, 0x04, 0x04, 0x18, 0x48, - 0x03, 0x00, 0x80, 0x40, 0x6A, 0x08, 0x81, 0x40, - 0x00, 0x00, 0x00, 0x80, 0x01, 0xE0, 0x82, 0x81, - 0x00, 0x00, 0x10, 0x07, 0x40, 0x18, 0x00, 0x00, - 0x00, 0x22, 0x31, 0x00, 0x80, 0x00, 0x02, 0x20, - 0x08, 0x00, 0x00, 0x50, 0x06, 0x08, 0x00, 0x02, - 0x78, 0x03, 0x00, 0x00, 0xA6, 0x06, 0x88, 0x20, - 0x08, 0x03, 0x08, 0x01, 0x00, 0x0A, 0x00, 0x02, - 0x80, 0x10, 0x00, 0x0C, 0x10, 0x00, 0x10, 0x80, - 0x10, 0x03, 0x84, 0x01, 0x82, 0x20, 0x94, 0xC0, - 0x10, 0x31, 0x19, 0x60, 0x11, 0x10, 0xA3, 0x80, - 0x02, 0x00, 0x50, 0x00, 0x00, 0x03, 0x49, 0x00, - 0x00, 0x02, 0x24, 0x60, 0x48, 0x00, 0x3C, 0x02, - 0xC8, 0x00, 0x00, 0x69, 0x00, 0xF1, 0x88, 0x20, - 0xA0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08, - 0x26, 0x08, 0x00, 0x00, 0x00, 0x40, 0x22, 0x00, - 0x52, 0x20, 0x84, 0x00, 0x01, 0x40, 0x00, 0x00, - 0x00, 0x88, 0x01, 0x22, 0x00, 0x00, 0x14, 0x40, - 0x00, 0x02, 0x00, 0x08, 0x00, 0x02, 0x00, 0x08, - 0x10, 0x00, 0x00, 0x80, 0x00, 0x00, 0x30, 0x4A, - 0x00, 0x21, 0x20, 0x00, 0x40, 0x44, 0x00, 0x40, - 0x00, 0x42, 0x44, 0x00, 0x00, 0x00, 0x40, 0x10, - 0x00, 0x80, 0x42, 0x40, 0x08, 0x00, 0x1A, 0x00, - 0x00, 0x8C, 0x05, 0x20, 0x00, 0x30, 0x00, 0x12, - 0x44, 0x1C, 0x01, 0x00, 0x18, 0x02, 0x40, 0x50, - 0x20, 0x00, 0x40, 0x00, 0x02, 0x00, 0x00, 0x03, - 0x80, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, - 0x60, 0x00, 0x1A, 0x2A, 0x00, 0x06, 0x20, 0x02, - 0x14, 0x11, 0x04, 0x00, 0x00, 0x22, 0x18, 0x04, - 0x00, 0xA0, 0xC8, 0x2C, 0x83, 0x00, 0x80, 0x40, - 0x20, 0x68, 0x41, 0x90, 0x00, 0x50, 0x01, 0x00, - 0x09, 0x80, 0x94, 0x82, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x20, 0x80, 0x10, 0xC0, 0x00, 0x00, - 0x04, 0x80, 0x00, 0x20, 0x02, 0x42, 0x4C, 0x80, - 0x00, 0x14, 0x00, 0x14, 0x01, 0x00, 0x80, 0x08, - 0x80, 0x00, 0x00, 0x2C, 0x21, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x02, 0x08, 0x25, 0x16, 0x00, 0x20, - 0x00, 0x60, 0x16, 0x09, 0x20, 0x42, 0x00, 0x00, - 0x00, 0xC4, 0x00, 0x08, 0x90, 0x40, 0x08, 0x20, - 0x00, 0x04, 0xA0, 0x80, 0x10, 0x80, 0x00, 0xC0, - 0x00, 0x00, 0xE0, 0x00, 0xF5, 0x02, 0x00, 0x00, - 0x04, 0x00, 0x08, 0x00, 0x70, 0x00, 0x44, 0x62, - 0x60, 0x26, 0x00, 0x00, 0x4C, 0x22, 0x4D, 0x18, - 0x24, 0x00, 0x11, 0x72, 0x0C, 0x08, 0x00, 0x14, - 0x01, 0x08, 0x00, 0x22, 0x44, 0x1A, 0x00, 0x08, - 0x11, 0x20, 0x80, 0x12, 0x03, 0xCC, 0x58, 0x01, - 0x41, 0x90, 0x84, 0x24, 0x65, 0x82, 0x89, 0x42, - 0x10, 0x40, 0x00, 0x00, 0x60, 0xB2, 0x99, 0x60, - 0x32, 0x08, 0x4C, 0x47, 0x40, 0x00, 0x10, 0xD4, - 0x00, 0x30, 0x00, 0xC0, 0x08, 0x08, 0x21, 0x11, - 0x0C, 0x12, 0x51, 0x24, 0x04, 0x20, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x4A, 0x44, 0x00, 0x10, 0x80, - 0x30, 0x00, 0x4C, 0x05, 0xD1, 0x20, 0xA4, 0x18, - 0x90, 0x42, 0x84, 0x20, 0x02, 0xA1, 0x02, 0x00, - 0x04, 0x00, 0xD5, 0x04, 0x08, 0x10, 0x1B, 0x04, - 0x01, 0x10, 0x04, 0x45, 0x0A, 0x1F, 0x05, 0x00, - 0x04, 0x1C, 0x19, 0x82, 0x81, 0x40, 0x80, 0x20, - 0x28, 0x49, 0x11, 0x88, 0x31, 0x08, 0x40, 0x04, - 0x8B, 0x13, 0x86, 0x40, 0x04, 0x04, 0xC0, 0x00, - 0x08, 0x18, 0x00, 0x00, 0x52, 0x00, 0x44, 0x84, - 0x94, 0x22, 0xC1, 0x88, 0x18, 0x02, 0x00, 0x24, - 0x88, 0x38, 0xBB, 0xE4, 0x40, 0x09, 0x40, 0x00, - 0x04, 0x04, 0x20, 0x01, 0xD0, 0x00, 0x20, 0x08, - 0x13, 0x14, 0x20, 0x80, 0x00, 0xC8, 0x42, 0x14, - 0x00, 0x18, 0x00, 0x41, 0x04, 0x02, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0xC4, 0x00, 0xC0, 0x01, - 0x84, 0x51, 0xF1, 0x00, 0x10, 0x80, 0xC8, 0x00, - 0x04, 0x01, 0x09, 0xB2, 0x00, 0x04, 0x41, 0x28, - 0x00, 0x28, 0x00, 0x10, 0x1C, 0x20, 0xC8, 0x01, - 0x82, 0x00, 0x14, 0x43, 0x00, 0x00, 0x04, 0xA0, - 0x20, 0x00, 0x44, 0x02, 0x01, 0x00, 0x9A, 0x44, - 0x0A, 0x81, 0x20, 0x29, 0x00, 0x00, 0x08, 0x3A, - 0x88, 0x08, 0x00, 0x84, 0x80, 0x62, 0x82, 0x15, - 0x22, 0x48, 0x81, 0x33, 0x42, 0x11, 0x04, 0x00, - 0x8A, 0x8A, 0x18, 0x3E, 0x22, 0x09, 0x40, 0x16, - 0x10, 0x65, 0x02, 0x11, 0x20, 0x60, 0x01, 0x28, - 0x58, 0x92, 0x4D, 0x44, 0x68, 0x34, 0x8C, 0x48, - 0x20, 0x10, 0x14, 0x00, 0x08, 0x81, 0x0A, 0x18, - 0x44, 0x90, 0x99, 0x51, 0x04, 0x02, 0x0A, 0x02, - 0xA2, 0x80, 0x61, 0x09, 0x0B, 0xC7, 0xC2, 0x40, - 0x10, 0x40, 0x02, 0x80, 0xC1, 0xC4, 0x80, 0x31, - 0x41, 0x04, 0x90, 0x02, 0xC2, 0x14, 0x90, 0x2C, - 0xAA, 0xC0, 0x20, 0x33, 0x00, 0x00, 0x88, 0x18, - 0x96, 0x81, 0x60, 0x18, 0x04, 0x40, 0x00, 0x68, - 0x01, 0x15, 0x04, 0xA2, 0x48, 0xC0, 0x01, 0x83, - 0x50, 0x06, 0x22, 0x00, 0x00, 0x60, 0x01, 0x10, - 0xC0, 0x01, 0x30, 0x0A, 0x49, 0x20, 0x15, 0x44, - 0x04, 0x01, 0x79, 0x0C, 0x18, 0x00, 0x10, 0x00, - 0x04, 0x04, 0x20, 0x64, 0xE9, 0x80, 0x00, 0x40, - 0x00, 0xC8, 0x04, 0x10, 0xB0, 0x02, 0x8C, 0x25, - 0x40, 0x84, 0x80, 0x0A, 0x30, 0x0E, 0x51, 0x14, - 0x08, 0x03, 0x48, 0x28, 0xD0, 0x00, 0x00, 0x08, - 0x00, 0x0C, 0x10, 0x00, 0x00, 0x50, 0x80, 0x40, - 0x2B, 0x50, 0x24, 0x28, 0x08, 0xB0, 0x88, 0x00, - 0x84, 0x0D, 0x02, 0x00, 0x21, 0x09, 0x00, 0x06, - 0x80, 0x84, 0x54, 0x03, 0x0C, 0x00, 0x00, 0x80, - 0x10, 0x61, 0x00, 0x80, 0x02, 0x40, 0x01, 0x02, - 0x00, 0x20, 0x08, 0x80, 0x08, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x10, 0xC0, 0x00, 0x00, 0x08, 0x00, - 0x40, 0x00, 0x00, 0x22, 0x80, 0x10, 0x00, 0x44, - 0x00, 0x12, 0x00, 0x20, 0x0A, 0x00, 0x28, 0x0A, - 0x00, 0x00, 0x00, 0x22, 0x00, 0x10, 0x00, 0x28, - 0x40, 0x00, 0x10, 0x10, 0x20, 0x82, 0x10, 0x88, - 0x00, 0x0B, 0x04, 0x44, 0x19, 0x20, 0x00, 0x00, - 0x02, 0x80, 0x20, 0x00, 0x00, 0x85, 0x00, 0x11, - 0x10, 0x00, 0x01, 0x44, 0x0A, 0x01, 0x00, 0x11, - 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x04, 0x80, 0x00, 0x90, 0x10, 0x00, 0x00, 0x02, - 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x48, 0x00, 0x22, 0x10, 0xAC, 0x00, 0x01, - 0x10, 0x66, 0x07, 0x4C, 0x1C, 0x00, 0x0C, 0x11, - 0x02, 0x00, 0x47, 0x62, 0x04, 0x84, 0x10, 0x00, - 0x00, 0x84, 0x00, 0x06, 0xD1, 0x01, 0x4C, 0xC0, - 0x00, 0x82, 0x00, 0x2C, 0x22, 0x22, 0x04, 0x20, - 0x11, 0x04, 0x09, 0x21, 0xA0, 0x20, 0x22, 0x15, - 0x00, 0x28, 0x00, 0x10, 0x63, 0x01, 0x4C, 0x43, - 0x0C, 0x00, 0x00, 0x00, 0x42, 0x04, 0x00, 0x40, - 0x00, 0x0A, 0x50, 0x04, 0x40, 0x00, 0x08, 0xC8, - 0x00, 0x00, 0x1C, 0x00, 0x21, 0x09, 0x20, 0x20, - 0x08, 0x16, 0x08, 0x40, 0x70, 0x08, 0x20, 0x26, - 0x98, 0x20, 0x00, 0x80, 0x03, 0x1C, 0x04, 0x89, - 0x0A, 0x08, 0x20, 0x02, 0x05, 0x35, 0xC0, 0x98, - 0x6C, 0x04, 0xC5, 0x40, 0x00, 0x04, 0x08, 0x08, - 0x12, 0x00, 0x80, 0x11, 0x01, 0x30, 0x02, 0xC8, - 0x00, 0x61, 0x42, 0x8C, 0x13, 0x0A, 0x00, 0x02, - 0x10, 0x00, 0x10, 0x40, 0x58, 0x00, 0x00, 0x10, - 0xA0, 0x18, 0x40, 0x00, 0x00, 0x90, 0x0C, 0x40, - 0x23, 0x0C, 0x44, 0x15, 0xC3, 0x68, 0x28, 0x08, - 0xEC, 0x8E, 0x80, 0x24, 0x48, 0x84, 0x10, 0x09, - 0x9C, 0x09, 0x04, 0x8A, 0xC1, 0xC1, 0xD8, 0x25, - 0x92, 0x29, 0x04, 0x10, 0x23, 0x04, 0x0A, 0x04, - 0x32, 0x80, 0x01, 0x08, 0x00, 0x80, 0x02, 0x00, - 0x00, 0x05, 0x86, 0x20, 0x43, 0x41, 0x29, 0x46, - 0x04, 0x00, 0x00, 0x20, 0x01, 0x00, 0x22, 0x60, - 0x12, 0x40, 0x8C, 0x0A, 0x8F, 0x0A, 0x01, 0x14, - 0x11, 0x10, 0x10, 0x50, 0x1A, 0x20, 0x02, 0x81, - 0x00, 0x80, 0x02, 0x00, 0x15, 0x04, 0x08, 0x28, - 0x60, 0x14, 0x80, 0x43, 0x40, 0x04, 0x20, 0xB2, - 0x34, 0x70, 0x0E, 0x02, 0x19, 0x71, 0x42, 0x08, - 0x00, 0x02, 0x00, 0x00, 0x62, 0x1C, 0x40, 0x02, - 0x20, 0x41, 0x0C, 0x10, 0x00, 0x00, 0x00, 0x28, - 0x1C, 0x01, 0xA0, 0x18, 0x00, 0x74, 0x00, 0x20, - 0xA2, 0x82, 0x00, 0x90, 0x40, 0x08, 0x82, 0x00, - 0x00, 0xD1, 0x82, 0xB0, 0x21, 0x80, 0x88, 0x20, - 0x44, 0x05, 0x10, 0x00, 0x0C, 0x09, 0x84, 0x00, - 0x80, 0x05, 0x42, 0x80, 0x81, 0x01, 0xE8, 0x00, - 0x00, 0x95, 0x17, 0x05, 0x10, 0x84, 0x0A, 0x19, - 0x10, 0x45, 0x40, 0xA1, 0x20, 0x14, 0x00, 0x09, - 0x04, 0x06, 0x10, 0x00, 0x04, 0x29, 0x00, 0x04, - 0x00, 0x60, 0x00, 0x5C, 0x00, 0x09, 0x00, 0xA0, - 0x00, 0x01, 0x8C, 0x00, 0x03, 0x10, 0x02, 0x00, - 0x00, 0x80, 0x41, 0x01, 0xF0, 0x20, 0x20, 0x18, - 0x06, 0x00, 0x30, 0x04, 0x00, 0x00, 0x94, 0x4A, - 0x20, 0x82, 0x40, 0x20, 0x10, 0x00, 0x18, 0x05, - 0x00, 0x90, 0x44, 0x86, 0x8D, 0x00, 0x00, 0x69, - 0x52, 0x03, 0x25, 0x00, 0x86, 0x00, 0x00, 0x06, - 0x14, 0x19, 0x40, 0x71, 0xAE, 0x52, 0x80, 0x40, - 0x08, 0x11, 0x00, 0x08, 0x00, 0x04, 0x40, 0x10, - 0x02, 0x80, 0x01, 0xB7, 0xE4, 0x00, 0x00, 0x82, - 0x11, 0x08, 0x03, 0x80, 0x02, 0x80, 0x00, 0x00, - 0x43, 0x02, 0xA3, 0x1F, 0xC2, 0x00, 0x02, 0x0B, - 0x00, 0x00, 0x04, 0x80, 0x01, 0x84, 0x18, 0x83, - 0x40, 0x88, 0x48, 0x42, 0x80, 0xA0, 0x41, 0xBF, - 0x65, 0x00, 0x40, 0x01, 0xC4, 0x00, 0x8B, 0xDA, - 0x3C, 0xC3, 0x34, 0x44, 0x61, 0x22, 0x02, 0x50, - 0xC0, 0x64, 0x02, 0x02, 0x00, 0x10, 0x0E, 0x4A, - 0xD4, 0xC0, 0x08, 0x40, 0x83, 0x20, 0x00, 0x06, - 0x10, 0x01, 0x10, 0x46, 0x80, 0x00, 0x42, 0x38, - 0x00, 0x00, 0x00, 0xE8, 0x30, 0x80, 0x00, 0x00, - 0x88, 0x04, 0x80, 0x90, 0x41, 0x00, 0x40, 0x15, - 0xF8, 0x31, 0x02, 0x21, 0x04, 0xAA, 0x10, 0x01, - 0x00, 0x00, 0x89, 0x04, 0x12, 0x04, 0x8E, 0x00, - 0xC0, 0x00, 0x20, 0x02, 0x44, 0x05, 0xF1, 0x00, - 0x18, 0x28, 0x01, 0x00, 0x18, 0x91, 0x01, 0x40, - 0x04, 0x0A, 0x41, 0x82, 0x00, 0x08, 0x01, 0x00, - 0x01, 0x04, 0x18, 0x02, 0x12, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0xA0, 0x10, 0x08, 0x90, - 0x00, 0xA0, 0x00, 0x20, 0x00, 0x10, 0x00, 0x02, - 0x08, 0x42, 0x38, 0x01, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x12, 0x01, 0x01, 0x98, 0x08, 0x04, 0x02, - 0x10, 0x02, 0x8B, 0x43, 0x82, 0x84, 0x41, 0x40, - 0x44, 0x40, 0x23, 0x91, 0x89, 0xCC, 0x03, 0x03, - 0x20, 0x00, 0x88, 0x04, 0x00, 0x04, 0x30, 0x88, - 0x00, 0x04, 0x40, 0x83, 0x30, 0x51, 0x41, 0x38, - 0x84, 0x00, 0x0A, 0x01, 0x82, 0x40, 0x14, 0x00, - 0x08, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x01, 0x48, 0x12, 0x02, 0x64, 0x30, - 0x4C, 0x60, 0x05, 0x00, 0x81, 0x10, 0x55, 0x82, - 0x84, 0xB9, 0x98, 0x54, 0x6C, 0x40, 0x43, 0x08, - 0x00, 0x89, 0x70, 0x22, 0x21, 0x29, 0x23, 0x16, - 0x20, 0x0A, 0x92, 0x05, 0x50, 0xE3, 0x30, 0x90, - 0xA8, 0x24, 0x88, 0xC4, 0xB4, 0x08, 0x11, 0xE0, - 0x00, 0x88, 0x00, 0x04, 0x62, 0x80, 0x11, 0x10, - 0x0A, 0xAA, 0xB0, 0x16, 0x82, 0x08, 0x64, 0x06, - 0x11, 0x08, 0x1B, 0x26, 0x0D, 0x80, 0x08, 0xA0, - 0x10, 0x00, 0x85, 0x01, 0x42, 0x52, 0x01, 0x00, - 0x01, 0x08, 0x45, 0xE3, 0x01, 0x47, 0x57, 0x30, - 0x20, 0x02, 0x91, 0x85, 0x00, 0x90, 0x00, 0x1C, - 0x00, 0x66, 0x88, 0x19, 0x13, 0xCE, 0x62, 0x00, - 0x28, 0x03, 0x01, 0x00, 0x20, 0x01, 0x00, 0x80, - 0x1A, 0x00, 0x00, 0x04, 0x00, 0x00, 0x45, 0x00, - 0x04, 0x21, 0x01, 0x9C, 0x80, 0x00, 0x20, 0x10, - 0x01, 0x40, 0x10, 0x61, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x02, 0xC8, 0x00, 0x01, 0x10, 0x15, - 0x84, 0x04, 0x15, 0x80, 0x02, 0x09, 0xB9, 0x1C, - 0x48, 0x00, 0x80, 0x81, 0x58, 0xA8, 0x90, 0x02, - 0x02, 0x10, 0x41, 0x4C, 0x81, 0x08, 0x88, 0x1C, - 0x16, 0x00, 0x00, 0x00, 0x32, 0x10, 0x8A, 0x28, - 0x40, 0x30, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, - 0xC4, 0x22, 0x0C, 0x02, 0x80, 0x00, 0x80, 0x00, - 0x08, 0x04, 0x62, 0x00, 0x00, 0x08, 0x10, 0x00, - 0x08, 0x56, 0x12, 0x00, 0x00, 0x18, 0x02, 0x14, - 0x45, 0x73, 0xC6, 0x8C, 0x28, 0x00, 0x00, 0x48, - 0x00, 0x01, 0xE0, 0x12, 0x00, 0x82, 0x86, 0x80, - 0x00, 0x82, 0x18, 0x28, 0x65, 0xA0, 0x00, 0x04, - 0x40, 0x90, 0x03, 0x04, 0x00, 0xA0, 0x10, 0xD0, - 0x40, 0x00, 0xD0, 0x42, 0x10, 0x08, 0x00, 0x01, - 0x40, 0x00, 0x10, 0x08, 0x00, 0x00, 0x60, 0x2A, - 0x42, 0x90, 0x00, 0x00, 0x08, 0x44, 0x08, 0x02, - 0x06, 0x20, 0x30, 0x44, 0x08, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, - 0x66, 0x02, 0x58, 0x48, 0x37, 0x20, 0x20, 0x00, - 0x00, 0x87, 0x01, 0xA1, 0x88, 0x02, 0x80, 0x81, - 0x68, 0x02, 0x88, 0xDB, 0x02, 0x0C, 0x03, 0x00, - 0x60, 0x10, 0x41, 0x95, 0x63, 0x04, 0x04, 0x1C, - 0x80, 0x50, 0x60, 0x41, 0x30, 0x10, 0x20, 0x03, - 0x00, 0x00, 0x20, 0x10, 0x8A, 0x80, 0x24, 0x21, - 0x40, 0x00, 0x30, 0x10, 0x20, 0x18, 0x11, 0x09, - 0x4C, 0x26, 0x07, 0x03, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x8C, - 0x04, 0x22, 0x8A, 0x20, 0x80, 0x08, 0x61, 0xE2, - 0xB4, 0x40, 0x0C, 0x00, 0x9A, 0x08, 0x2C, 0x06, - 0x02, 0x82, 0x00, 0x05, 0xC0, 0x18, 0x6C, 0x36, - 0x74, 0x81, 0x52, 0x08, 0x0E, 0x59, 0xC0, 0x80, - 0x10, 0x04, 0x2A, 0x51, 0x80, 0x60, 0x49, 0x11, - }; -// Failed to handle 800 words. -// POINT: 1 diff --git a/hash_generator.c b/hash_generator.c deleted file mode 100644 index 5308b3c..0000000 --- a/hash_generator.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is used to generate the bloom filter for word - * checking. - * Build: clang -o hash_generator ../bloom.c hash_generator.c - */ - -#include - -#include "../bloom.h" - -int main(int argc, char *argv[]) { - unsigned int bloom_size = 5000; - bloom_t bloom = bloom_create(bloom_size); - FILE *f = fopen(argv[1], "r"); - char wordbuf[6]; - wordbuf[5] = 0; - int invalid = 0; - while(1) { - - if(fread(wordbuf, 5, 1, f) != 1) { - break; - } - int before = bloom_test(bloom, wordbuf); - bloom_add(bloom, wordbuf); - int after = bloom_test(bloom, wordbuf); - - if(before == after) { - invalid ++; - } - fread(wordbuf, 1, 1, f); // skip newline - } - - - // print contents - printf("const size_t bloom_data_len = %d;\n", bloom_size); - printf("uint8_t bloom_data[] = {\n\t"); - uint8_t *bits = bloom->bits; - for(int i = 0; i < bloom_size; i++) { - printf("0x%02X, ", bits[i]); - if((i+1) % 8 == 0) { - printf("\n\t"); - } - } - printf("};\n"); - printf("// Failed to handle %d words.\n", invalid); -} diff --git a/main.c b/main.c index b81b9dd..721458b 100644 --- a/main.c +++ b/main.c @@ -13,15 +13,13 @@ #include #include -#include "wordlist.h" -#include "filter.h" -#include "bloom.h" +#include "word-db.h" +#define MAX_GUESSES 6 void set_box_color_for_letter(char *word, int position, char letter); void set_letter_color_for_letter(char *word, int position, char letter); -bloom_t bloom; const char *kb[3] = { "Q W E R T Y U I O P", " A S D F G H J K L", @@ -42,12 +40,12 @@ int kb_offsets[3] = { int kb_x = 0; int kb_y = 0; int guess_nr; -char guess[6]; -char guesses[6][5]; +char guess[WORD_LENGTH+1]; +char guesses[WORD_LENGTH+1][MAX_GUESSES]; char guessed_wrong[30]; char guessed_position[30]; char guessed_correct[30]; -char word[6]; +char word[WORD_LENGTH+1]; void draw_word_rect(int x, int y, char *guess) { int gx = x/8; @@ -192,7 +190,7 @@ void render_guess() { } void draw_board() { - for(int i=0; i < 6; i++) { + for(int i=0; i < MAX_GUESSES; i++) { char *g = NULL; if(i < guess_nr) { g = guesses[i]; @@ -206,7 +204,7 @@ void draw_board() { void show_win() { color(BLACK, BLACK, M_FILL); - box(0, 0, 160, 144, M_FILL); + box(0, 0, SCREENWIDTH, SCREENHEIGHT, M_FILL); gotogxy(0, 8); color(WHITE, BLACK, M_NOFILL); gprint(" You won!!!"); @@ -219,7 +217,7 @@ void show_win() { void show_loose() { // cls(); color(BLACK, BLACK, M_FILL); - box(0, 0, 160, 144, M_FILL); + box(0, 0, SCREENWIDTH, SCREENHEIGHT, M_FILL); gotogxy(0, 8); color(WHITE, BLACK, M_NOFILL); gprint(" You lost. Sorry!"); @@ -229,7 +227,7 @@ void show_loose() { void analyze_guess(char *guess) { - for(int i =0; i < 5; i++) { + for(int i = 0; i < WORD_LENGTH; i++) { if(guess[i] == word[i]) { guessed_correct[strlen(guessed_correct)] = guess[i]; } else if(contains(word, guess[i])) { @@ -246,15 +244,15 @@ void run_wordle(void) int has_random = 0; guess_nr = 0; - memset(guess, 0, 5); - memset(guessed_wrong, 0, 30); - memset(guessed_position, 0, 30); - memset(guessed_correct, 0, 30); + memset(guess, 0, sizeof(guess)); + memset(guessed_wrong, 0, sizeof(guessed_wrong)); + memset(guessed_position, 0, sizeof(guessed_position)); + memset(guessed_correct, 0, sizeof(guessed_correct)); - for(int i=0; i < 6; i++) { + for(int i=0; i < MAX_GUESSES; i++) { strcpy(guesses[i], ""); } - for(int i=0; i < 6; i++) { + for(int i=0; i < MAX_GUESSES; i++) { draw_word_rect(40, 16+(i*16), NULL); } @@ -274,7 +272,7 @@ void run_wordle(void) while(r > 211) { r = rand(); } - strcpy(word, words[r]); + get_word(r, word); has_random = 1; } @@ -323,9 +321,8 @@ void run_wordle(void) break; case J_SELECT: case J_START: - if(strlen(guess) != 5) break; - if(!bloom_test(bloom, guess)) break; - // bool bloom_test(bloom_t filter, const void *item); + if(strlen(guess) != WORD_LENGTH) break; + if(!query_word(guess)) break; analyze_guess(guess); strcpy(guesses[guess_nr], guess); guess_nr += 1; @@ -337,7 +334,7 @@ void run_wordle(void) return; break; } - if(guess_nr == 6) { + if(guess_nr == MAX_GUESSES) { show_loose(); return; break; @@ -347,7 +344,7 @@ void run_wordle(void) // TODO break; case J_A: - if(strlen(guess) == 5) break; + if(strlen(guess) == WORD_LENGTH) break; guess[strlen(guess)] = getletter(); render_guess(); waitpadup(); @@ -367,10 +364,6 @@ void run_wordle(void) } void main() { - // Initialize bloom filter - bloom = bloom_create_existing(bloom_data_len, bloom_data); - bloom_add_hash(bloom, djb2); - while(1) { run_wordle(); } diff --git a/word-db.c b/word-db.c new file mode 100644 index 0000000..e8673cc --- /dev/null +++ b/word-db.c @@ -0,0 +1,85 @@ + +#include "word-db.h" + +word_number_t from_b26(char word[const WORD_LENGTH+1]) { + word_number_t res = 0; + word_number_t pow = 1; + for(uint8_t i = WORD_LENGTH; i > 0; i--) { + word_number_t digit = word[i-1]-'A'; + res += digit*pow; + pow *= 26; + } + + return res; +} + +void to_b26(word_number_t word_number, char word[WORD_LENGTH+1]) { + uint8_t i = 0; + while(word_number > 0) { + word[WORD_LENGTH - 1 - i] = 'A' + (word_number % 26); + word_number /= 26; + i++; + } + for(;i < WORD_LENGTH; i++) { + word[WORD_LENGTH - 1 - i] = 'A'; + } +} + +bool query_word(char word[const WORD_LENGTH+1]) { + if(true == query_word_compressed(word_guesses, guesses_index, word)) { + return true; + } + if(true == query_word_compressed(word_answers, answers_index, word)) { + return true; + } + return false; +} + +void add_unpack_varint(const uint8_t* const varint, word_number_t *current_word, wordlist_size_t *current_offset) { + *current_word += 1; + for(uint8_t i = 0; ; i++) { + const uint8_t b = varint[(*current_offset)++]; + const uint32_t value = b & 0x7F; + const uint8_t more = b & 0x80; + *current_word += value << (7*i); + if(more == 0) { + break; + } + } +} + +bool query_word_compressed(const uint8_t* const words, const index_entry* const index, char word[const WORD_LENGTH+1]) { + // TODO: permutation optimization + const word_number_t word_number = from_b26(word); + const word_index_size_t bucket_idx = word[0] - 'A'; + const index_entry *bucket = &index[bucket_idx]; + const index_entry *bucket_end = &index[bucket_idx+1]; + + if(bucket->start_word == word_number) { + return true; + } + + word_number_t current_word = bucket->start_word; + wordlist_size_t current_offset = bucket->offset; + while(current_offset < bucket_end->offset) { + add_unpack_varint(words, ¤t_word, ¤t_offset); + if(word_number == current_word) { + return true; + } + } + return false; +} + +void get_word(wordlist_size_t index, char word[WORD_LENGTH+1]) { + get_word_compressed(word_answers, index, word); +} + +void get_word_compressed(const uint8_t* const words, wordlist_size_t index, char word[const WORD_LENGTH+1]) { + word_number_t current_word = 0; + wordlist_size_t current_offset = 0; + for(wordlist_size_t i = 0; i <= index; i++) { + add_unpack_varint(words, ¤t_word, ¤t_offset); + } + + to_b26(current_word, word); +} diff --git a/word-db.h b/word-db.h new file mode 100644 index 0000000..70ff009 --- /dev/null +++ b/word-db.h @@ -0,0 +1,33 @@ +#include +#include + +#define WORD_LENGTH 5 + +typedef uint32_t word_number_t; +typedef uint16_t wordlist_size_t; +typedef uint8_t word_index_size_t; +typedef struct { + word_number_t start_word; + wordlist_size_t offset; +} index_entry; + +extern const wordlist_size_t word_answers_size; +extern const uint8_t word_answers[]; +extern const word_index_size_t answers_index_size; +extern const index_entry answers_index[]; + +extern const wordlist_size_t word_guesses_size; +extern const uint8_t word_guesses[]; +extern const word_index_size_t guesses_index_size; +extern const index_entry guesses_index[]; + +// public +bool query_word(char word[const WORD_LENGTH+1]); +void get_word(wordlist_size_t index, char word[WORD_LENGTH+1]); + +// private +bool query_word_compressed(const uint8_t* const words, const index_entry* const index, char word[const WORD_LENGTH+1]); +void get_word_compressed(const uint8_t* const words, wordlist_size_t index, char word[const WORD_LENGTH+1]); + +word_number_t from_b26(char word[const WORD_LENGTH+1]); +void to_b26(word_number_t word_number, char word[WORD_LENGTH+1]); diff --git a/wordle_compress/.gitignore b/wordle_compress/.gitignore new file mode 100644 index 0000000..1f52cd5 --- /dev/null +++ b/wordle_compress/.gitignore @@ -0,0 +1,3 @@ +word-db-test +wordlist_answers.txt +wordlist_guesses.txt diff --git a/wordle_compress/Makefile b/wordle_compress/Makefile new file mode 100644 index 0000000..2d59d76 --- /dev/null +++ b/wordle_compress/Makefile @@ -0,0 +1,4 @@ + +word-db-test: word-db-test.c ../word-db.h ../word-db.c ../words.c + gcc -o word-db-test word-db-test.c ../word-db.h ../word-db.c ../words.c + diff --git a/wordle_compress/generate_words.py b/wordle_compress/generate_words.py new file mode 100644 index 0000000..4c24309 --- /dev/null +++ b/wordle_compress/generate_words.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python3 + +import string +import sys + +C_FILE_TEMPLATE = """ +#include "word-db.h" + +const wordlist_size_t word_answers_size = %d; +const uint8_t word_answers[] = { %s }; +const word_index_size_t answers_index_size = %d; +const index_entry answers_index[] = { + //{ .offset = 0, .start_word = 0 } + %s +}; + +const wordlist_size_t word_guesses_size = %d; +const uint8_t word_guesses[] = { %s }; +const word_index_size_t guesses_index_size = %d; +const index_entry guesses_index[] = { + //{ .offset = 0, .start_word = 0 } + %s +}; +""" + +def pack_varint(num): + """Pack a number as a variable length integer""" + assert num > 0 + num -= 1 + if num == 0: + return bytes([0]) + res = [] + while num > 0: + part = num & 0x7F + num = num >> 7 + if num > 0: + part |= 0x80 + res.append(part) + return bytes(res) + +def unpack_varint(data): + """Unpack a variable length integer into a number""" + res = 0 + for i, b in enumerate(data): + value = b & 0x7F + more = b >> 7 + res += value << (7*i) + if more == 0: + break + return res+1, i+1 + +def from_b26(word, l=5): + """Convert a word into a number by treating it as a base 26 number""" + assert len(word) == l, len(word) + assert all(x in string.ascii_lowercase for x in word), word + res = 0 + for i, c in enumerate(word.encode('ascii')[::-1]): + res += (c-ord('a'))*26**i + return res + +def to_b26(word, l=5): + """Convert a number into a word by converting it into a base 26 number""" + digits = [] + while word > 0: + digits.append(word % 26) + word = word // 26 + + return ''.join(string.ascii_lowercase[x] for x in digits[::-1]).rjust(l, 'a') + + +def compress_wordlist_varlen(words): + """Compress a list of words into a delta encoded sequence of variable length integers""" + word_numbers = [from_b26(word) for word in words] + current = 0 + res = b'' + for word_number in word_numbers: + delta = word_number - current + assert delta > 0 + packed = pack_varint(delta) + res += packed + current = word_number + + return res + +def decompress_wordlist_varlen(compressed): + """Decompress a list of words from a delta encoded sequence of variable length integers""" + words = [] + current_word = 0 + current = 0 + + while current < len(compressed): + delta, word_len = unpack_varint(compressed[current:]) + current_word += delta + current += word_len + words.append(to_b26(current_word)) + + return words + +def build_index(compressed_words): + buckets = [(None, None)]*26 + current_word = 0 + current = 0 + prev_bucket_idx = -1 + while current < len(compressed_words): + delta, word_len = unpack_varint(compressed_words[current:]) + current_word += delta + current += word_len + bucket_idx = current_word // 26**4 + if bucket_idx != prev_bucket_idx: + buckets[bucket_idx] = (current, current_word) + prev_bucket_idx = bucket_idx + buckets.append((len(compressed_words), 0)) + + for i in range(len(buckets)-1, -1, -1): + if buckets[i-1][0] == None: + buckets[i-1] = (buckets[i][0], 0xffffffff) + + return buckets + +def main(): + if len(sys.argv) < 4: + print(f'Usage: {sys.argv[0]} ') + return -1 + + with open(sys.argv[1], 'r') as fin: + words1 = sorted(word.strip() for word in fin) + with open(sys.argv[2], 'r') as fin: + words2 = sorted(word.strip() for word in fin) + + print(f'Number of answer words: {len(words1)}') + if len(words1) != 2315: + print('Warning: Not using the official Wordle wordlist for answers') + words1_sorted = sorted(words1) + words1_compressed = compress_wordlist_varlen(words1_sorted) + print(f'Compressed size: {len(words1_compressed)}') + words1_decompressed = decompress_wordlist_varlen(words1_compressed) + print(f'Decompression correct: {words1_decompressed == words1_sorted}') + + words1_hex = ', '.join(f'{x:#04x}' for x in words1_compressed) + words1_buckets = build_index(words1_compressed) + words1_buckets_c = ',\n '.join(f'{{ .offset = {offset}, .start_word = {start_word:#x} }}' for offset, start_word in words1_buckets) + + print(f'Number of valid guess words: {len(words2)}') + if len(words2) != 10657: + print('Warning: Not using the official Wordle wordlist for valid guesses') + words2_sorted = sorted(words2) + words2_compressed = compress_wordlist_varlen(words2_sorted) + print(f'Compressed size: {len(words2_compressed)}') + words2_decompressed = decompress_wordlist_varlen(words2_compressed) + print(f'Decompression correct: {words2_decompressed == words2_sorted}') + + words2_hex = ', '.join(f'{x:#04x}' for x in words2_compressed) + words2_buckets = build_index(words2_compressed) + words2_buckets_c = ',\n '.join(f'{{ .offset = {offset}, .start_word = {start_word:#x} }}' for offset, start_word in words2_buckets) + + words2_hex = ', '.join(f'{x:#04x}' for x in words2_compressed) + + with open(sys.argv[3], 'w') as fout: + fout.write(C_FILE_TEMPLATE % ( + len(words1_compressed), words1_hex, len(words1_buckets), words1_buckets_c, + len(words2_compressed), words2_hex, len(words2_buckets), words2_buckets_c, + )) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/wordle_compress/word-db-test.c b/wordle_compress/word-db-test.c new file mode 100644 index 0000000..c6163ce --- /dev/null +++ b/wordle_compress/word-db-test.c @@ -0,0 +1,29 @@ +#include +#include + +#include "../word-db.h" + +int main() { + char word1[6] = ""; + char word2[6] = ""; + strncpy(word1, "SOARE", sizeof(word1)); + uint32_t test1 = from_b26(word1); + to_b26(test1, word2); + printf("Word: %s -> %x -> %s\n", word1, test1, word2); + + + get_word(0, word1); + printf("Word[0]: %s\n", word1); + + printf("SOARE: %d\n", query_word("SOARE")); + printf("ABACK: %d\n", query_word("ABACK")); + printf("SOARE: %d\n", query_word("SOARE")); + printf("XXXXX: %d\n", query_word("XXXXX")); + printf("AAHED: %d\n", query_word("AAHED")); + printf("AAHEF: %d\n", query_word("AAHEF")); + printf("ZYMIC: %d\n", query_word("ZYMIC")); + printf("ZYMIB: %d\n", query_word("ZYMIB")); + printf("BEADS: %d\n", query_word("BEADS")); + + return 0; +} diff --git a/wordlist.h b/wordlist.h deleted file mode 100644 index cb8a44b..0000000 --- a/wordlist.h +++ /dev/null @@ -1,214 +0,0 @@ -const char *words[212] = { - "ABUSE", - "ADULT", - "AGENT", - "ANGER", - "APPLE", - "AWARD", - "BASIS", - "BEACH", - "BIRTH", - "BLOCK", - "BLOOD", - "BOARD", - "BRAIN", - "BREAD", - "BREAK", - "BROWN", - "BUYER", - "CAUSE", - "CHAIN", - "CHAIR", - "CHEST", - "CHIEF", - "CHILD", - "CHINA", - "CLAIM", - "CLASS", - "CLOCK", - "COACH", - "COAST", - "COURT", - "COVER", - "CREAM", - "CRIME", - "CROSS", - "CROWD", - "CROWN", - "CYCLE", - "DANCE", - "DEATH", - "DEPTH", - "DOUBT", - "DRAFT", - "DRAMA", - "DREAM", - "DRESS", - "DRINK", - "DRIVE", - "EARTH", - "ENEMY", - "ENTRY", - "ERROR", - "EVENT", - "FAITH", - "FAULT", - "FIELD", - "FIGHT", - "FINAL", - "FLOOR", - "FOCUS", - "FORCE", - "FRAME", - "FRANK", - "FRONT", - "FRUIT", - "GLASS", - "GRANT", - "GRASS", - "GREEN", - "GROUP", - "GUIDE", - "HEART", - "HENRY", - "HORSE", - "HOTEL", - "HOUSE", - "IMAGE", - "INDEX", - "INPUT", - "ISSUE", - "JAPAN", - "JONES", - "JUDGE", - "KNIFE", - "LAURA", - "LAYER", - "LEVEL", - "LEWIS", - "LIGHT", - "LIMIT", - "LUNCH", - "MAJOR", - "MARCH", - "MATCH", - "METAL", - "MODEL", - "MONEY", - "MONTH", - "MOTOR", - "MOUTH", - "MUSIC", - "NIGHT", - "NOISE", - "NORTH", - "NOVEL", - "NURSE", - "OFFER", - "ORDER", - "OTHER", - "OWNER", - "PANEL", - "PAPER", - "PARTY", - "PEACE", - "PETER", - "PHASE", - "PHONE", - "PIECE", - "PILOT", - "PITCH", - "PLACE", - "PLANE", - "PLANT", - "PLATE", - "POINT", - "POUND", - "POWER", - "PRESS", - "PRICE", - "PRIDE", - "PRIZE", - "PROOF", - "QUEEN", - "RADIO", - "RANGE", - "RATIO", - "REPLY", - "RIGHT", - "RIVER", - "ROUND", - "ROUTE", - "RUGBY", - "SCALE", - "SCENE", - "SCOPE", - "SCORE", - "SENSE", - "SHAPE", - "SHARE", - "SHEEP", - "SHEET", - "SHIFT", - "SHIRT", - "SHOCK", - "SIGHT", - "SIMON", - "SKILL", - "SLEEP", - "SMILE", - "SMITH", - "SMOKE", - "SOUND", - "SOUTH", - "SPACE", - "SPEED", - "SPITE", - "SPORT", - "SQUAD", - "STAFF", - "STAGE", - "START", - "STATE", - "STEAM", - "STEEL", - "STOCK", - "STONE", - "STORE", - "STUDY", - "STUFF", - "STYLE", - "SUGAR", - "TABLE", - "TASTE", - "TERRY", - "THEME", - "THING", - "TITLE", - "TOTAL", - "TOUCH", - "TOWER", - "TRACK", - "TRADE", - "TRAIN", - "TREND", - "TRIAL", - "TRUST", - "TRUTH", - "UNCLE", - "UNION", - "UNITY", - "VALUE", - "VIDEO", - "VISIT", - "VOICE", - "WASTE", - "WATCH", - "WATER", - "WHILE", - "WHITE", - "WHOLE", - "WOMAN", - "WORLD", - "YOUTH" -}; diff --git a/words.c.tpl b/words.c.tpl new file mode 100644 index 0000000..7f931cc --- /dev/null +++ b/words.c.tpl @@ -0,0 +1,16 @@ +#include "word-db.h" + +const wordlist_size_t word_answers_size = 1; +const uint8_t word_answers[] = { 0 }; +const word_index_size_t answers_index_size = 1; +const index_entry answers_index[] = { + { .offset = 0, .start_word = 0 } +}; + +const wordlist_size_t word_guesses_size = 1; +const uint8_t word_guesses[] = { 0 }; +const word_index_size_t guesses_index_size = 1; +extern const index_entry guesses_index[] = { + { .offset = 0, .start_word = 0 } +}; +