惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
博客园 - 司徒正美
博客园 - Franky
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
量子位
博客园 - 叶小钗
博客园_首页
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Solving Wordle with information theory: entropy, guess tr...
Dean Gilley · 2026-04-24 · via DEV Community

Solving Wordle with information theory: entropy, guess trees, and why greedy wins

If you spent any time on the internet in early 2022, you likely saw the viral sensation that was Wordle. While most players were relying on intuition or a lucky "ADIEU" opener, the engineering community was busy treating the game as a classic information theory problem.

At its core, Wordle is a game of reducing uncertainty. Every time you submit a guess, the game provides a feedback pattern (gray, yellow, or green). This feedback acts as a filter, narrowing down the set of possible secret words. To solve the game efficiently, we don't just want to guess words; we want to maximize the information we gain from each guess.

The Math: Shannon Entropy

In information theory, we measure the "surprise" or information content of an event using Shannon entropy. For a given guess, we want to choose a word that splits the remaining possible secret words into the most balanced "buckets" of feedback patterns.

If a guess splits the remaining words into $N$ possible feedback patterns, where each pattern $i$ occurs with probability $p_i$, the entropy $H$ is defined as:

$$H = -\sum_{i=1}^{N} p_i \log_2(p_i)$$

A guess that results in a uniform distribution of feedback patterns—where every possible outcome is equally likely—maximizes entropy. This is the "gold standard" for a first guess.

Implementing Entropy in Python

Calculating this is surprisingly straightforward. We need to simulate the feedback for every possible secret word in our list and group them by the resulting pattern.

import math
from collections import Counter

def calculate_entropy(guess, possible_words):
    patterns = []
    for secret in possible_words:
        # get_feedback returns a tuple like (0, 1, 2, 0, 0)
        patterns.append(get_feedback(guess, secret))

    counts = Counter(patterns)
    total = len(possible_words)
    entropy = 0

    for count in counts.values():
        p = count / total
        entropy -= p * math.log2(p)
    return entropy

Enter fullscreen mode Exit fullscreen mode

Why TARES beats ADIEU

Many players swear by "ADIEU" because it hits four vowels. However, from an information theory perspective, "ADIEU" is suboptimal. It is a "vowel-heavy" strategy that often results in highly skewed feedback. You might get a lot of yellow letters, but you haven't effectively partitioned the remaining word space.

"TARES," on the other hand, is a powerhouse. It hits high-frequency consonants (T, R, S) and a common vowel (A, E). When you run the entropy calculation across the standard Wordle dictionary, "TARES" (or "SALET" or "CRANE") consistently provides a higher average information gain. It doesn't just tell you what is in the word; it effectively eliminates large swaths of the dictionary that aren't.

If you want to see how these strategies hold up against different word lists, if you want to play with real Wordle variants, you can test your own openers against various constraints.

Greedy vs. Minimax: The Search for Perfection

The "greedy" approach—picking the word with the highest entropy at each step—is incredibly effective. It will solve the vast majority of Wordle puzzles in 3 to 4 guesses. However, it is not mathematically "optimal."

A greedy solver only looks one step ahead. It optimizes for the next guess, not the final guess. To achieve the theoretical minimum of 3.42 guesses, you need a Minimax approach.

A Minimax solver builds a full decision tree. It asks: "If I pick word X, what is the worst-case scenario for the remaining number of guesses?" It then chooses the move that minimizes that worst-case outcome.

def minimax(guess, possible_words, depth):
    if len(possible_words) <= 2:
        return len(possible_words)

    # Branching factor: simulate all possible feedback patterns
    # This is computationally expensive!
    scores = []
    for pattern in get_all_possible_patterns(guess):
        subset = filter_words(possible_words, guess, pattern)
        scores.append(max_depth_for_subset(subset))
    return max(scores)

Enter fullscreen mode Exit fullscreen mode

While the greedy approach is a simple loop, the Minimax approach requires a recursive search through a massive state space. It is the difference between a quick script and a heavy-duty search algorithm. If you ever get stuck on a particularly brutal daily puzzle, a2zwords.com can serve as a helpful companion tool to see what the "optimal" path might have looked like.

Moving to Production

If you were to build a production-grade Wordle solver, you would quickly run into performance bottlenecks. Here is how you would scale it:

  1. Memoization/Caching: The state space of Wordle is finite. You should cache the entropy results for every (guess, remaining_word_list) tuple. Once you've calculated the entropy of "CRANE" for a specific subset of words, you never need to calculate it again.
  2. Bitmasking: Instead of storing words as strings, represent them as bitmasks. Comparing a guess to a secret word becomes a series of bitwise AND/OR operations, which are orders of magnitude faster than string manipulation.
  3. Polyglot Dictionaries: A production solver should handle multiple languages. By decoupling the solver logic from the dictionary file (using JSON or SQLite), you can swap between English, Spanish, or even custom word lists without changing a line of code.

Wordle is a perfect example of how a simple game can be transformed into a rigorous exercise in computer science. Whether you prefer the quick-and-dirty greedy approach or the exhaustive perfection of a Minimax tree, the math remains the same: it’s all about maximizing the information you extract from every single guess.