|
|
@@ -1,5 +1,3 @@
|
|
|
-import type { SolverStep } from '@wordle/shared';
|
|
|
-
|
|
|
function getFeedback(target: string, guess: string): string {
|
|
|
const tu = target.toLowerCase(), gu = guess.toLowerCase();
|
|
|
const counts: Record<string, number> = {};
|
|
|
@@ -25,9 +23,9 @@ function scoreWord(word: string, freq: Record<string, number>): number {
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
-export function solveFrequency(target: string, allWords: string[], maxAttempts = 6): { attempts: number; steps: SolverStep[] } {
|
|
|
+export function solveFrequency(target: string, allWords: string[], maxAttempts = 6): { attempts: number; steps: string[] } {
|
|
|
let candidates = [...allWords];
|
|
|
- const steps: SolverStep[] = [];
|
|
|
+ const steps: string[] = [];
|
|
|
|
|
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
|
const freq = letterFrequency(candidates);
|
|
|
@@ -36,7 +34,7 @@ export function solveFrequency(target: string, allWords: string[], maxAttempts =
|
|
|
for (const g of pool) { const s = scoreWord(g, freq); if (s > bestScore) { bestScore = s; bestGuess = g; } }
|
|
|
|
|
|
const fb = getFeedback(target, bestGuess);
|
|
|
- steps.push({ guess: bestGuess });
|
|
|
+ steps.push(bestGuess);
|
|
|
if (fb === 'ggggg') return { attempts: attempt, steps };
|
|
|
|
|
|
candidates = candidates.filter((c) => getFeedback(c, bestGuess) === fb);
|