"""Wordle Solver feedback reference v1; synthetic equality patterns, no dictionary. Run with Python 3. Uses all set partitions of the ten ordered positions in guess+target. Renaming letters cannot change this disclosed feedback rule. Uniform pattern counts are NOT frequencies of real words or daily answers. """ from collections import Counter from pathlib import Path import json BASE = Path(__file__).resolve().parent def score(guess, target): out = ['b'] * 5 remaining = Counter() for i in range(5): if guess[i] == target[i]: out[i] = 'g' else: remaining[target[i]] += 1 for i, letter in enumerate(guess): if out[i] != 'g' and remaining[letter]: out[i] = 'y' remaining[letter] -= 1 return ''.join(out) def oracle(guess, target): # Independent positional matching implementation, without letter counters. exact = {i for i in range(5) if guess[i] == target[i]} unused = set(range(5)) - exact out = [] for i, letter in enumerate(guess): if i in exact: out.append('g') continue matches = sorted(j for j in unused if target[j] == letter) if matches: unused.remove(matches[0]) out.append('y') else: out.append('b') return ''.join(out) def partitions(prefix=(0,)): if len(prefix) == 10: yield ''.join(chr(65 + x) for x in prefix) return for value in range(max(prefix) + 2): yield from partitions(prefix + (value,)) def generate(): cases = [('eerie', 'erase'), ('allee', 'apple'), ('array', 'cigar'), ('belle', 'level'), ('sassy', 'stand'), ('mamma', 'gamma'), ('hello', 'hello'), ('cigar', 'blunt'), ('eagle', 'eerie'), ('level', 'belle'), ('babba', 'aaabb'), ('aaaaa', 'abaca')] examples = [{'guess': g, 'target': t, 'pattern': score(g, t), 'syntheticPair': True} for g, t in cases] assert score('eerie', 'erase') == 'gbybg' assert score('sassy', 'stand') == 'gybbb' assert score('aaabb', 'babba') == 'ygbgy' total, naive_errors, invariant_checks = 0, 0, 0 distribution = Counter() for pattern in partitions(): guess, target = pattern[:5], pattern[5:] actual = score(guess, target) assert actual == oracle(guess, target), (guess, target, actual) naive = ''.join('g' if g == t else 'y' if g in target else 'b' for g, t in zip(guess, target)) naive_errors += actual != naive for letter in set(guess): positive = sum(g == letter and c != 'b' for g, c in zip(guess, actual)) assert positive == min(guess.count(letter), target.count(letter)) invariant_checks += 1 total += 1 distribution[actual] += 1 assert total == 115975 return {'version': '1.0.0', 'scope': 'all equality patterns of ordered 5+5 positions, up to bijective letter renaming', 'pairCount': total, 'twoIndependentImplementationsDisagree': 0, 'letterCountInvariantChecks': invariant_checks, 'naiveMembershipDisagreements': naive_errors, 'probabilityInterpretation': False, 'feedbackDistribution': dict(sorted(distribution.items())), 'examples': examples} if __name__ == '__main__': result = generate() (BASE / 'results-v1.json').write_text(json.dumps(result, indent=2) + '\n') (BASE / 'examples-v1.json').write_text(json.dumps(result['examples'], indent=2) + '\n') print(json.dumps({k: v for k, v in result.items() if k not in ['feedbackDistribution', 'examples']}, indent=2))