Files
quartiles/scripts/build-all-data.mjs
2026-10-24 14:15:31 -04:00

441 lines
28 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import { solveBoard } from './solver.mjs';
import { extraWords } from './extra-words.mjs';
import { DICTIONARY_SET } from '../src/data/lexicon.js';
export const targetWordsPool = [
// Wonder & Exploration
{ word: 'remarkable', tiles: ['re', 'mar', 'ka', 'ble'], theme: 'wonder', clue: 'Worthy of attention; striking' },
{ word: 'unforgettable', tiles: ['un', 'for', 'get', 'table'], theme: 'wonder', clue: 'Impossible to forget; memorable' },
{ word: 'photography', tiles: ['pho', 'to', 'gra', 'phy'], theme: 'wonder', clue: 'The art or practice of taking photos' },
{ word: 'adventurous', tiles: ['ad', 'ven', 'tur', 'ous'], theme: 'wonder', clue: 'Willing to take risks or try new things' },
{ word: 'inspiration', tiles: ['in', 'spi', 'ra', 'tion'], theme: 'wonder', clue: 'A stimulus to creative thought or action' },
// Space & Cosmos
{ word: 'astronomy', tiles: ['as', 'tro', 'no', 'my'], theme: 'space', clue: 'The branch of science dealing with space' },
{ word: 'gravitation', tiles: ['gra', 'vi', 'ta', 'tion'], theme: 'space', clue: 'The force that attracts bodies toward mass' },
{ word: 'atmosphere', tiles: ['at', 'mo', 'sph', 'ere'], theme: 'space', clue: 'The envelope of gases surrounding a planet' },
{ word: 'interstellar', tiles: ['in', 'ter', 'ste', 'llar'], theme: 'space', clue: 'Occurring between stars' },
{ word: 'telescopic', tiles: ['tel', 'es', 'co', 'pic'], theme: 'space', clue: 'Having the power for viewing distant objects' },
{ word: 'constellation', tiles: ['con', 'ste', 'lla', 'tion'], theme: 'space', clue: 'A group of stars forming a pattern' },
{ word: 'stratosphere', tiles: ['stra', 'tos', 'phe', 're'], theme: 'space', clue: 'Layer of the atmosphere above troposphere' },
// Mind & Philosophy
{ word: 'imagination', tiles: ['im', 'agi', 'na', 'tion'], theme: 'mind', clue: 'The faculty of forming new ideas or images' },
{ word: 'understanding', tiles: ['un', 'der', 'stan', 'ding'], theme: 'mind', clue: 'The ability to comprehend something' },
{ word: 'psychology', tiles: ['psy', 'cho', 'lo', 'gy'], theme: 'mind', clue: 'The scientific study of mind and behavior' },
{ word: 'intelligence', tiles: ['in', 'tel', 'li', 'gence'], theme: 'mind', clue: 'The ability to acquire and apply knowledge' },
{ word: 'consciousness', tiles: ['con', 'sci', 'ous', 'ness'], theme: 'mind', clue: 'The state of being aware of surroundings' },
{ word: 'philosophy', tiles: ['phi', 'los', 'op', 'hy'], theme: 'mind', clue: 'The study of fundamental nature of knowledge' },
{ word: 'thoughtfulness', tiles: ['thou', 'ght', 'ful', 'ness'], theme: 'mind', clue: 'The state of thinking deeply or being caring' },
// Architecture & City
{ word: 'architecture', tiles: ['ar', 'chi', 'tec', 'ture'], theme: 'city', clue: 'The art and practice of designing buildings' },
{ word: 'metropolitan', tiles: ['me', 'tro', 'pol', 'itan'], theme: 'city', clue: 'Relating to a large, busy city' },
{ word: 'construction', tiles: ['con', 'stru', 'cti', 'on'], theme: 'city', clue: 'The building of something typically large' },
{ word: 'neighborhood', tiles: ['neigh', 'bor', 'ho', 'od'], theme: 'city', clue: 'A district or area forming a community' },
{ word: 'skyscraper', tiles: ['sky', 'sc', 'ra', 'per'], theme: 'city', clue: 'A very tall building with many stories' },
// Music & Arts
{ word: 'masterpiece', tiles: ['mas', 'ter', 'pie', 'ce'], theme: 'arts', clue: 'A work of outstanding artistry or skill' },
{ word: 'calligraphy', tiles: ['cal', 'lig', 'ra', 'phy'], theme: 'arts', clue: 'Decorative handwriting or handwritten lettering' },
{ word: 'exhibition', tiles: ['ex', 'hi', 'bi', 'tion'], theme: 'arts', clue: 'A public display of works of art or items' },
{ word: 'creativity', tiles: ['cre', 'at', 'iv', 'ity'], theme: 'arts', clue: 'The use of the imagination or original ideas' },
{ word: 'choreography', tiles: ['cho', 'reo', 'gra', 'phy'], theme: 'arts', clue: 'The sequence of steps and movements in dance' },
// Technology & Future
{ word: 'technology', tiles: ['tec', 'hno', 'lo', 'gy'], theme: 'tech', clue: 'Application of scientific knowledge for practical aims' },
{ word: 'electronic', tiles: ['el', 'ect', 'ro', 'nic'], theme: 'tech', clue: 'Having components like microchips or transistors' },
{ word: 'automation', tiles: ['au', 'to', 'ma', 'tion'], theme: 'tech', clue: 'The use of largely automatic equipment in a system' },
{ word: 'cybersecurity', tiles: ['cy', 'ber', 'sec', 'urity'], theme: 'tech', clue: 'Protection of computer systems from attack or theft' },
{ word: 'motherboard', tiles: ['mo', 'ther', 'bo', 'ard'], theme: 'tech', clue: 'A printed circuit board containing principal components' },
// Celebrations & Community
{ word: 'celebration', tiles: ['cel', 'eb', 'ra', 'tion'], theme: 'society', clue: 'The action of marking pleasure at an event' },
{ word: 'fellowship', tiles: ['fel', 'low', 'sh', 'ip'], theme: 'society', clue: 'Friendly association, especially with shared interests' },
{ word: 'generosity', tiles: ['gen', 'ero', 'si', 'ty'], theme: 'society', clue: 'The quality of being kind and generous' },
{ word: 'opportunity', tiles: ['op', 'por', 'tu', 'nity'], theme: 'society', clue: 'A set of circumstances making something possible' },
{ word: 'marshmallow', tiles: ['mar', 'shm', 'all', 'ow'], theme: 'society', clue: 'A sweet chewy confection made of sugar and gelatin' },
{ word: 'hospitality', tiles: ['hos', 'pit', 'al', 'ity'], theme: 'society', clue: 'Friendly and generous reception of guests' },
{ word: 'friendship', tiles: ['fri', 'end', 'sh', 'ip'], theme: 'society', clue: 'A state of mutual trust and support between people' },
// Nature & Wild Kingdom
{ word: 'biodiversity', tiles: ['bio', 'di', 'ver', 'sity'], theme: 'nature', clue: 'The variety of life in the world or habitat' },
{ word: 'environment', tiles: ['en', 'vi', 'ron', 'ment'], theme: 'nature', clue: 'The surroundings or conditions in which one lives' },
{ word: 'caterpillar', tiles: ['cat', 'er', 'pil', 'lar'], theme: 'nature', clue: 'The larval stage of a butterfly or moth' },
{ word: 'wilderness', tiles: ['wil', 'der', 'ne', 'ss'], theme: 'nature', clue: 'An uncultivated, uninhabited, and hospitable region' },
{ word: 'chameleon', tiles: ['cha', 'me', 'le', 'on'], theme: 'nature', clue: 'A lizard capable of changing skin color' },
{ word: 'hummingbird', tiles: ['hum', 'ming', 'bi', 'rd'], theme: 'nature', clue: 'Small nectar-feeding bird with hovering flight' },
{ word: 'woodpecker', tiles: ['wood', 'pe', 'ck', 'er'], theme: 'nature', clue: 'A bird with a strong beak for drilling into wood' },
{ word: 'butterflies', tiles: ['but', 'ter', 'fli', 'es'], theme: 'nature', clue: 'Insects with large, often brightly colored wings' },
{ word: 'grasshoppers', tiles: ['grass', 'hop', 'pe', 'rs'], theme: 'nature', clue: 'Plant-eating insect with powerful hind legs for jumping' },
// Mysteries & Legends
{ word: 'mysterious', tiles: ['mys', 'ter', 'io', 'us'], theme: 'mystery', clue: 'Difficult or impossible to understand or explain' },
{ word: 'supernatural', tiles: ['su', 'per', 'nat', 'ural'], theme: 'mystery', clue: 'Attributed to some force beyond scientific understanding' },
{ word: 'enchanted', tiles: ['en', 'cha', 'nt', 'ed'], theme: 'mystery', clue: 'Placed under a spell; bewitched' },
{ word: 'miraculous', tiles: ['mi', 'rac', 'ul', 'ous'], theme: 'mystery', clue: 'Occurring through divine or extraordinary intervention' },
// Science & Discovery
{ word: 'equivalent', tiles: ['equ', 'iv', 'al', 'ent'], theme: 'science', clue: 'Equal in value, amount, function, or meaning' },
{ word: 'hypothesis', tiles: ['hy', 'pot', 'he', 'sis'], theme: 'science', clue: 'A proposed explanation made on limited evidence' },
{ word: 'laboratory', tiles: ['lab', 'ora', 'to', 'ry'], theme: 'science', clue: 'A room or building equipped for scientific experiments' },
{ word: 'microscope', tiles: ['mi', 'cro', 'sco', 'pe'], theme: 'science', clue: 'Optical instrument for magnifying tiny objects' },
{ word: 'phenomenon', tiles: ['phe', 'nom', 'en', 'on'], theme: 'science', clue: 'A remarkable fact or situation that is observed to happen' },
// Literature & Wordsmith
{ word: 'dictionary', tiles: ['dic', 'tio', 'na', 'ry'], theme: 'words', clue: 'A reference book on words and definitions' },
{ word: 'manuscript', tiles: ['man', 'us', 'cr', 'ipt'], theme: 'words', clue: 'An author text that has not yet been printed' },
{ word: 'encyclopedia', tiles: ['en', 'cy', 'clo', 'pedia'], theme: 'words', clue: 'A book or set providing information on many subjects' },
{ word: 'literature', tiles: ['li', 'ter', 'at', 'ure'], theme: 'words', clue: 'Written works, especially those considered of superior merit' },
// Travel & Geography
{ word: 'backpacker', tiles: ['back', 'pa', 'ck', 'er'], theme: 'travel', clue: 'A traveler who journeys carrying their belongings' },
{ word: 'locomotive', tiles: ['lo', 'co', 'mo', 'tive'], theme: 'travel', clue: 'A powered rail vehicle used for pulling trains' },
{ word: 'continental', tiles: ['con', 'tin', 'en', 'tal'], theme: 'travel', clue: 'Forming or belonging to a continent' },
{ word: 'navigation', tiles: ['na', 'vi', 'ga', 'tion'], theme: 'travel', clue: 'The process of accurately ascertaining one position and course' },
{ word: 'voyagers', tiles: ['vo', 'ya', 'ge', 'rs'], theme: 'travel', clue: 'People who go on a long journey, typically by sea or space' },
// Weather & Atmosphere
{ word: 'meteorology', tiles: ['me', 'teo', 'rol', 'ogy'], theme: 'weather', clue: 'The science of atmospheric processes and forecasting' },
{ word: 'temperatures', tiles: ['tem', 'per', 'at', 'ures'], theme: 'weather', clue: 'The degrees of heat present in substance or area' },
{ word: 'precipitation', tiles: ['pre', 'cip', 'ita', 'tion'], theme: 'weather', clue: 'Rain, snow, sleet, or hail falling to the ground' },
{ word: 'cloudburst', tiles: ['clo', 'ud', 'bur', 'st'], theme: 'weather', clue: 'A sudden, violent rainstorm' },
{ word: 'thunderstorm', tiles: ['thun', 'der', 'sto', 'rm'], theme: 'weather', clue: 'A storm with thunder and lightning and heavy rain' },
// Botany & Plants
{ word: 'photosynthesis', tiles: ['pho', 'tos', 'yn', 'thesis'], theme: 'plants', clue: 'Process by which green plants synthesize nutrients' },
{ word: 'evergreen', tiles: ['ev', 'er', 'gre', 'en'], theme: 'plants', clue: 'A plant that retains green leaves throughout the year' },
{ word: 'germination', tiles: ['ger', 'mi', 'na', 'tion'], theme: 'plants', clue: 'The development of a plant from a seed or spore' },
{ word: 'sunflowers', tiles: ['sun', 'flo', 'we', 'rs'], theme: 'plants', clue: 'Tall plants with very large, daisy-like yellow flowers' },
// Grit & Endeavor
{ word: 'determination', tiles: ['de', 'ter', 'mi', 'nation'], theme: 'endeavor', clue: 'Firmness of purpose; resoluteness' },
{ word: 'courageous', tiles: ['cou', 'rag', 'eo', 'us'], theme: 'endeavor', clue: 'Not deterred by danger or pain; brave' },
{ word: 'championship', tiles: ['cham', 'pion', 'sh', 'ip'], theme: 'endeavor', clue: 'A competition to decide the victor or champion' },
{ word: 'achievement', tiles: ['ach', 'iev', 'em', 'ent'], theme: 'endeavor', clue: 'A thing done successfully with effort, skill, or courage' },
{ word: 'perseverance', tiles: ['per', 'sev', 'era', 'nce'], theme: 'endeavor', clue: 'Persistence in doing something despite difficulty' },
// Oceanic Depths
{ word: 'oceanography', tiles: ['oce', 'ano', 'gra', 'phy'], theme: 'ocean', clue: 'The branch of science that deals with physical oceans' },
{ word: 'underwater', tiles: ['un', 'der', 'wa', 'ter'], theme: 'ocean', clue: 'Situated or occurring below water surface' },
{ word: 'exploration', tiles: ['ex', 'plo', 'ra', 'tion'], theme: 'ocean', clue: 'The action of traveling through an unfamiliar area' },
// Physics & Energy
{ word: 'electricity', tiles: ['el', 'ect', 'ri', 'city'], theme: 'physics', clue: 'Form of energy from charged elementary particles' },
{ word: 'radioactive', tiles: ['rad', 'ioa', 'cti', 've'], theme: 'physics', clue: 'Emitting ionizing radiation from nuclei' },
{ word: 'magnetism', tiles: ['mag', 'ne', 'ti', 'sm'], theme: 'physics', clue: 'A physical phenomenon produced by the motion of electric charge' },
// Additional 100+ unique words for Random Unlimited Generator
{ word: 'kaleidoscope', tiles: ['kal', 'eid', 'osc', 'ope'], theme: 'arts', clue: 'Optical instrument with reflective surfaces showing patterns' },
{ word: 'rollercoaster', tiles: ['rol', 'ler', 'coas', 'ter'], theme: 'fun', clue: 'Amusement park ride with steep slopes and curves' },
{ word: 'firecracker', tiles: ['fi', 'rec', 'rac', 'ker'], theme: 'fun', clue: 'A loud explosive firework' },
{ word: 'helicopter', tiles: ['he', 'li', 'cop', 'ter'], theme: 'travel', clue: 'Aircraft with horizontally rotating blades' },
{ word: 'motorcycle', tiles: ['mo', 'tor', 'cy', 'cle'], theme: 'travel', clue: 'Two-wheeled vehicle powered by an engine' },
{ word: 'candlestick', tiles: ['can', 'dle', 'sti', 'ck'], theme: 'craft', clue: 'A holder with a socket or spike for a candle' },
{ word: 'peppermint', tiles: ['pep', 'per', 'mi', 'nt'], theme: 'food', clue: 'A pungent herb or sweet flavoring' },
{ word: 'cheesecake', tiles: ['chee', 'se', 'ca', 'ke'], theme: 'food', clue: 'A rich sweet dessert made with soft cheese' },
{ word: 'gingerbread', tiles: ['gin', 'ger', 'bre', 'ad'], theme: 'food', clue: 'A cake or cookie flavored with ginger and molasses' },
{ word: 'blueberries', tiles: ['blue', 'ber', 'ri', 'es'], theme: 'food', clue: 'Small sweet blue-colored edible berries' },
{ word: 'strawberries', tiles: ['straw', 'ber', 'ri', 'es'], theme: 'food', clue: 'Sweet juicy red fruit with seeds on surface' },
{ word: 'waterproofing', tiles: ['wa', 'ter', 'pro', 'ofing'], theme: 'craft', clue: 'Making an object impervious to water' },
{ word: 'troubleshooter', tiles: ['trou', 'ble', 'shoo', 'ter'], theme: 'tech', clue: 'Someone who identifies and solves problems' },
{ word: 'heartwarming', tiles: ['hea', 'rtw', 'arm', 'ing'], theme: 'emotion', clue: 'Evoking feelings of happiness and contentment' },
{ word: 'groundbreaking', tiles: ['gro', 'und', 'bre', 'aking'], theme: 'endeavor', clue: 'Innovative; applying new ideas' },
{ word: 'brainstorming', tiles: ['bra', 'inst', 'orm', 'ing'], theme: 'mind', clue: 'Spontaneous group discussion to produce ideas' },
{ word: 'superpower', tiles: ['su', 'per', 'po', 'wer'], theme: 'society', clue: 'An exceptionally powerful nation or ability' },
{ word: 'leadership', tiles: ['lead', 'er', 'sh', 'ip'], theme: 'society', clue: 'The action of leading a group or organization' },
{ word: 'brotherhood', tiles: ['bro', 'ther', 'ho', 'od'], theme: 'society', clue: 'An association or community of people' },
{ word: 'windsurfers', tiles: ['wind', 'sur', 'fe', 'rs'], theme: 'sports', clue: 'Person who engages in board sailing' },
{ word: 'thermometer', tiles: ['ther', 'mo', 'me', 'ter'], theme: 'science', clue: 'Instrument for measuring temperature' },
{ word: 'barometer', tiles: ['ba', 'rom', 'et', 'er'], theme: 'science', clue: 'Instrument measuring atmospheric pressure' },
{ word: 'speedometer', tiles: ['spee', 'dom', 'et', 'er'], theme: 'science', clue: 'Instrument on a vehicle indicating speed' },
{ word: 'oceanfront', tiles: ['oce', 'anf', 'ro', 'nt'], theme: 'nature', clue: 'Land facing directly toward the ocean' },
{ word: 'rainforest', tiles: ['rain', 'fo', 're', 'st'], theme: 'nature', clue: 'A dense forest rich in biodiversity' },
{ word: 'waterfalls', tiles: ['wa', 'ter', 'fa', 'lls'], theme: 'nature', clue: 'Cascade of water falling from a height' },
{ word: 'dragonflies', tiles: ['dra', 'gon', 'fli', 'es'], theme: 'nature', clue: 'Fast-flying insects with long bodies and two pairs of wings' },
{ word: 'sandwiches', tiles: ['sand', 'wi', 'ch', 'es'], theme: 'food', clue: 'Slices of bread with filling between them' },
{ word: 'shortbread', tiles: ['sho', 'rtb', 're', 'ad'], theme: 'food', clue: 'A crisp rich crumbly biscuit' },
{ word: 'blacksmith', tiles: ['bla', 'cks', 'mi', 'th'], theme: 'craft', clue: 'A person who makes and repairs things in iron' },
{ word: 'silversmith', tiles: ['sil', 'ver', 'smi', 'th'], theme: 'craft', clue: 'A person who crafts objects out of silver' },
{ word: 'locksmiths', tiles: ['loc', 'ksm', 'it', 'hs'], theme: 'craft', clue: 'People who make and repair locks' },
{ word: 'woodworking', tiles: ['wood', 'wor', 'ki', 'ng'], theme: 'craft', clue: 'The activity or skill of making items from wood' },
{ word: 'shipbuilder', tiles: ['ship', 'bui', 'ld', 'er'], theme: 'craft', clue: 'A person or business that designs and constructs ships' },
{ word: 'watchmakers', tiles: ['wat', 'chm', 'ake', 'rs'], theme: 'craft', clue: 'Artisans who make and repair watches' },
{ word: 'matchmakers', tiles: ['mat', 'chm', 'ake', 'rs'], theme: 'society', clue: 'People who arrange marriages or partnerships' },
{ word: 'homemakers', tiles: ['hom', 'em', 'ake', 'rs'], theme: 'society', clue: 'People who manage a household' },
{ word: 'gatekeepers', tiles: ['gat', 'eke', 'ep', 'ers'], theme: 'society', clue: 'Attendants controlling access through an entrance' },
{ word: 'peacekeeper', tiles: ['pea', 'cek', 'eep', 'er'], theme: 'society', clue: 'A person maintaining peace, especially in conflict zones' },
{ word: 'bookkeeper', tiles: ['boo', 'kke', 'ep', 'er'], theme: 'business', clue: 'A person whose job is to keep financial records' },
{ word: 'shopkeeper', tiles: ['sho', 'pke', 'ep', 'er'], theme: 'business', clue: 'An owner or manager of a small shop' },
{ word: 'cheerleader', tiles: ['che', 'erl', 'ead', 'er'], theme: 'sports', clue: 'A member of a team that leads cheering' },
{ word: 'trendsetter', tiles: ['tre', 'nds', 'ett', 'er'], theme: 'society', clue: 'A person who leads the way in fashion or ideas' },
{ word: 'ghostwriter', tiles: ['gho', 'stw', 'rit', 'er'], theme: 'words', clue: 'A person hired to write literary or journalistic work' },
{ word: 'screenwriter', tiles: ['scr', 'een', 'wri', 'ter'], theme: 'arts', clue: 'A person who writes screenplays for films' },
{ word: 'playwrights', tiles: ['pla', 'ywr', 'igh', 'ts'], theme: 'arts', clue: 'People who write plays' },
{ word: 'songwriters', tiles: ['son', 'gwr', 'ite', 'rs'], theme: 'arts', clue: 'Musicians who write musical compositions and lyrics' },
{ word: 'headmasters', tiles: ['hea', 'dma', 'ste', 'rs'], theme: 'education', clue: 'Teachers in charge of a school' },
{ word: 'grandmaster', tiles: ['gra', 'ndm', 'ast', 'er'], theme: 'games', clue: 'The highest title awarded to a chess player' },
{ word: 'quarterback', tiles: ['qua', 'rte', 'rba', 'ck'], theme: 'sports', clue: 'A player in American football directing play' },
{ word: 'sweatshirts', tiles: ['swe', 'atsh', 'ir', 'ts'], theme: 'clothes', clue: 'Loose warm casual cotton pullover shirts' },
{ word: 'turtlenecks', tiles: ['tur', 'tle', 'nec', 'ks'], theme: 'clothes', clue: 'High, close-fitting turned-over collars' },
{ word: 'windbreaker', tiles: ['win', 'dbr', 'eak', 'er'], theme: 'clothes', clue: 'A wind-resistant lightweight jacket' },
{ word: 'silverback', tiles: ['sil', 'ver', 'ba', 'ck'], theme: 'nature', clue: 'An older mature male mountain gorilla' },
{ word: 'paddleboard', tiles: ['pad', 'dle', 'bo', 'ard'], theme: 'sports', clue: 'A long board propelled with a paddle' },
{ word: 'springboard', tiles: ['spr', 'ing', 'bo', 'ard'], theme: 'sports', clue: 'A flexible board used in diving or gymnastics' },
{ word: 'checkerboard', tiles: ['che', 'cke', 'rbo', 'ard'], theme: 'games', clue: 'A game board divided into sixty-four squares' },
{ word: 'blackboards', tiles: ['bla', 'ckb', 'oar', 'ds'], theme: 'education', clue: 'Dark reusable writing surfaces for chalk' },
{ word: 'whiteboards', tiles: ['whi', 'teb', 'oar', 'ds'], theme: 'education', clue: 'Glossy white boards for nonpermanent markers' },
{ word: 'noticeboards', tiles: ['not', 'ice', 'boa', 'rds'], theme: 'society', clue: 'Boards for displaying notices or advertisements' },
];
// Merge expanded word list (skip invalid entries with a warning instead of failing)
{
const existing = new Set(targetWordsPool.map(w => w.word));
let added = 0;
for (const item of extraWords) {
const problems = [];
if (existing.has(item.word)) problems.push('duplicate word');
if (item.tiles.length !== 4) problems.push('not 4 tiles');
if (item.tiles.join('') !== item.word) problems.push(`tiles spell "${item.tiles.join('')}"`);
if (!item.tiles.every(t => t.length >= 2)) problems.push('tile < 2 letters');
if (new Set(item.tiles).size !== item.tiles.length) problems.push('repeated tile within word');
if (!DICTIONARY_SET.has(item.word)) problems.push('not in runtime dictionary');
if (problems.length) {
console.warn(` Skipping extra word "${item.word}": ${problems.join(', ')}`);
continue;
}
existing.add(item.word);
targetWordsPool.push(item);
added++;
}
console.log(`Merged ${added} extra target words.`);
}
// Validate pool integrity
for (const item of targetWordsPool) {
if (item.tiles.join('') !== item.word) {
throw new Error(`Word spelling mismatch: ${item.word} !== ${item.tiles.join('')}`);
}
if (!item.tiles.every(t => t.length >= 2)) {
throw new Error(`Word contains tile < 2 chars: ${item.word} -> ${JSON.stringify(item.tiles)}`);
}
if (item.tiles.length !== 4) {
throw new Error(`Word does not have 4 tiles: ${item.word}`);
}
}
console.log('Target words pool verified! Total words:', targetWordsPool.length);
const dailyPuzzlesDefs = [
{
id: '2026-10-23',
date: '2026-10-23',
title: 'Daily Puzzle — Oct 23, 2026',
theme: 'Discovery & Wonder',
difficulty: 'Normal',
words: ['remarkable', 'unforgettable', 'photography', 'adventurous', 'inspiration']
},
{
id: '2026-10-24',
date: '2026-10-24',
title: 'Daily Puzzle — Oct 24, 2026',
theme: 'Cosmic Horizons',
difficulty: 'Challenging',
words: ['astronomy', 'gravitation', 'atmosphere', 'interstellar', 'telescopic']
},
{
id: '2026-10-25',
date: '2026-10-25',
title: 'Daily Puzzle — Oct 25, 2026',
theme: 'Mind & Memory',
difficulty: 'Normal',
words: ['imagination', 'understanding', 'psychology', 'intelligence', 'consciousness']
},
{
id: '2026-10-26',
date: '2026-10-26',
title: 'Daily Puzzle — Oct 26, 2026',
theme: 'Urban Pulse',
difficulty: 'Challenging',
words: ['architecture', 'metropolitan', 'construction', 'neighborhood', 'skyscraper']
},
{
id: '2026-10-27',
date: '2026-10-27',
title: 'Daily Puzzle — Oct 27, 2026',
theme: 'Harmony & Arts',
difficulty: 'Normal',
words: ['saxophone', 'masterpiece', 'calligraphy', 'exhibition', 'creativity']
},
{
id: '2026-10-28',
date: '2026-10-28',
title: 'Daily Puzzle — Oct 28, 2026',
theme: 'Digital Future',
difficulty: 'Normal',
words: ['technology', 'electronic', 'automation', 'computer', 'cybersecurity']
},
{
id: '2026-10-29',
date: '2026-10-29',
title: 'Daily Puzzle — Oct 29, 2026',
theme: 'Celebrations',
difficulty: 'Easy',
words: ['celebration', 'fellowship', 'generosity', 'opportunity', 'marshmallow']
},
{
id: '2026-10-30',
date: '2026-10-30',
title: 'Daily Puzzle — Oct 30, 2026',
theme: 'Wild Kingdom',
difficulty: 'Normal',
words: ['biodiversity', 'environment', 'caterpillar', 'wilderness', 'chameleon']
},
{
id: '2026-10-31',
date: '2026-10-31',
title: 'Daily Puzzle — Oct 31, 2026',
theme: 'Mysteries & Legends',
difficulty: 'Challenging',
words: ['mysterious', 'supernatural', 'legendary', 'enchanted', 'miraculous']
},
{
id: '2026-10-22',
date: '2026-10-22',
title: 'Daily Puzzle — Oct 22, 2026',
theme: 'Scientific Insight',
difficulty: 'Normal',
words: ['equivalent', 'hypothesis', 'laboratory', 'microscope', 'phenomenon']
},
{
id: '2026-10-21',
date: '2026-10-21',
title: 'Daily Puzzle — Oct 21, 2026',
theme: 'Wordsmith Almanac',
difficulty: 'Normal',
words: ['dictionary', 'manuscript', 'encyclopedia', 'literature', 'vocabulary']
},
{
id: '2026-10-20',
date: '2026-10-20',
title: 'Daily Puzzle — Oct 20, 2026',
theme: 'Globe Trekker',
difficulty: 'Normal',
words: ['backpacker', 'locomotive', 'continental', 'navigation', 'voyagers']
},
{
id: '2026-10-19',
date: '2026-10-19',
title: 'Daily Puzzle — Oct 19, 2026',
theme: 'Atmospheric Skies',
difficulty: 'Challenging',
words: ['meteorology', 'temperatures', 'precipitation', 'stratosphere', 'cloudburst']
},
{
id: '2026-10-18',
date: '2026-10-18',
title: 'Daily Puzzle — Oct 18, 2026',
theme: 'Green Oasis',
difficulty: 'Normal',
words: ['photosynthesis', 'marigold', 'evergreen', 'germination', 'sunflowers']
},
{
id: '2026-10-17',
date: '2026-10-17',
title: 'Daily Puzzle — Oct 17, 2026',
theme: 'Grit & Glory',
difficulty: 'Normal',
words: ['determination', 'courageous', 'championship', 'achievement', 'perseverance']
},
{
id: '2026-10-16',
date: '2026-10-16',
title: 'Daily Puzzle — Oct 16, 2026',
theme: 'Oceanic Depths',
difficulty: 'Challenging',
words: ['oceanography', 'submarine', 'underwater', 'jellyfish', 'exploration']
},
{
id: '2026-10-15',
date: '2026-10-15',
title: 'Daily Puzzle — Oct 15, 2026',
theme: 'Energy & Waves',
difficulty: 'Expert',
words: ['electricity', 'spectrum', 'frequency', 'radioactive', 'magnetism']
}
];
// Map target words for quick lookup
const wordMap = new Map();
for (const item of targetWordsPool) {
wordMap.set(item.word, item);
}
const solvedPuzzles = [];
for (const def of dailyPuzzlesDefs) {
const quartets = def.words.map(w => {
const found = wordMap.get(w);
if (!found) throw new Error('Missing word in pool: ' + w);
return found.tiles;
});
const allTiles = quartets.flat();
// STRICT ASSERTIONS
if (new Set(allTiles).size !== 20) {
const counts = {};
allTiles.forEach(t => counts[t] = (counts[t] || 0) + 1);
const dupes = Object.entries(counts).filter(([_, c]) => c > 1);
throw new Error(`Puzzle ${def.id} has duplicate tiles: ${JSON.stringify(dupes)}`);
}
if (allTiles.some(t => t.length < 2)) {
throw new Error(`Puzzle ${def.id} has a tile < 2 chars: ${JSON.stringify(allTiles)}`);
}
const solved = solveBoard(quartets, 30);
if (solved.wordCount > 30) {
throw new Error(`Puzzle ${def.id} exceeds 30 words: ${solved.wordCount}`);
}
// Add clues to target quartiles
const quartileDetails = def.words.map(w => {
const item = wordMap.get(w);
return {
word: item.word,
tiles: item.tiles,
clue: item.clue
};
});
solvedPuzzles.push({
id: def.id,
date: def.date,
title: def.title,
theme: def.theme,
difficulty: def.difficulty,
quartets,
tiles: solved.tiles,
targetQuartiles: solved.targetQuartiles,
quartileDetails,
words: solved.words,
wordCount: solved.wordCount,
maxPossibleScore: solved.maxPossibleScore
});
console.log(`Generated: ${def.id} [${def.theme}] -> ${solved.wordCount} words, max score: ${solved.maxPossibleScore}`);
}
// Write solved puzzles to src/data/puzzles.js
const puzzlesFileContent = `// Pre-computed solved daily and themed puzzles for Quartiles
export const CURATED_PUZZLES = ${JSON.stringify(solvedPuzzles, null, 2)};
export const TARGET_WORDS_POOL = ${JSON.stringify(targetWordsPool, null, 2)};
`;
fs.mkdirSync('src/data', { recursive: true });
fs.writeFileSync('src/data/puzzles.js', puzzlesFileContent, 'utf8');
console.log('Saved src/data/puzzles.js successfully!');