A Node.js simulation of the Countdown letter stack management system, including duplicate extraction and word probability ranking.
This project simulates the Countdown letter distribution and management system as described in the chat. It models:
- Letter Distribution: Uses the official Countdown letter frequencies (42 vowels, 56 consonants)
- Duplicate Management: Simulates the "extract consecutive duplicates to the end" method
- Word Ranking: Ranks English words by their likelihood of being formable with the managed stack
- Stack Creation: Creates letter stacks based on official Countdown distribution
- Duplicate Extraction: Efficiently removes consecutive duplicates by moving them to the end
- Simulation: Simulates complete letter rounds with configurable vowel/consonant counts
- Analysis: Analyzes managed stack frequencies through Monte Carlo simulation
- Dictionary Filtering: Filters English dictionary to valid Countdown words (≤9 letters)
- Probability Calculation: Calculates word formation probability using managed stack frequencies
- Word Ranking: Ranks words by their likelihood of being formable
npm install# Test the duplicate extraction algorithm
node countdown-simulator.js test
# Simulate a letter round (4 vowels, 5 consonants)
node countdown-simulator.js simulate 4 5 true
# Analyze vowel stack frequencies
node countdown-simulator.js analyze vowels 9 10000
# Analyze consonant stack frequencies
node countdown-simulator.js analyze consonants 9 10000# Rank words by probability (10,000 iterations, top 50 words)
node word-ranker.js rank 10000 50
# Test word filtering and probability calculation
node word-ranker.js testAfter duplicate extraction, the top 9 positions show:
Vowels:
- E: ~28.4% (down from ~31.3% in raw distribution)
- A: ~22.7% (down from ~22.4% in raw distribution)
- O: ~20.1% (up from ~19.4% in raw distribution)
- I: ~20.0% (up from ~19.4% in raw distribution)
- U: ~8.9% (up from ~7.5% in raw distribution)
Consonants:
- R: ~12.0% (up from ~16.1% in raw distribution)
- S: ~11.9% (up from ~16.1% in raw distribution)
- T: ~11.5% (up from ~16.1% in raw distribution)
- N: ~10.4% (up from ~14.3% in raw distribution)
The system identifies words that are most likely to be formable, typically:
- Short words (1-2 letters) with high-frequency letters
- Words with diverse vowel/consonant combinations
- Words avoiding duplicate letters (since duplicates are pushed to the end)
The algorithm efficiently removes consecutive duplicates by:
- Scanning the shuffled stack from left to right
- Keeping the first occurrence of each letter in sequence
- Collecting all consecutive duplicates
- Appending all duplicates to the end
This ensures no consecutive duplicates remain while preserving the total letter count.
Word probability is calculated by:
- Counting each letter in the word
- Looking up the managed probability for each letter
- Multiplying probabilities (simplified approach - doesn't account for drawing without replacement)
- Ranking words by total probability
countdown-simulator.js: Main simulation engineword-ranker.js: Word ranking and analysispackage.json: Project dependenciesREADME.md: This documentation
an-array-of-english-words: English dictionary for word analysis
MIT