SM'S DEX

Terminal Wordle Engine & Call Tree Visualizer

An interactive behavioral replica of Shivam Mahajan's pure C Wordle game engine running via native WebAssembly (Wasm). Features real-time C function pipeline tracking, duplicate letter frequency analysis, and custom polynomial hash table lookups with zero runtime libraries.

Pure C99 Zero External Dependencies Native WebAssembly (2.4 KB) O(1) Hash Table Two-Pass Duplicate Handling
wordle.c terminal session WASM INITIALIZING... PLAYING
Seed: day+month
// Pure C99 Wordle Stdout Stream
Welcome to Wordle!
Single word challenge for the whole day.
6 tries to guess a 5-letter word.
Green: Correct spot | Yellow: Misplaced | Red: Not in word
----------------------------------------

Active Call Tree & Pipeline

Zero External Libs
STEP 1 fgets(input, 1000, stdin) & strcspn()
wordle.c
Reads raw buffer from terminal stdin, strips newline terminator, validates exactly 5 letters.
char input[1000]; input[strcspn(input, "\n")] = '\0';
STEP 2 checkAlpha(guess)
src/wordcheck.c
Scans each byte via isalpha(). Rejects non-alphabetic glyphs, empty strings, or null pointers.
int checkAlpha(char *guess); // O(N) where N=5
STEP 3 hashfunction2(input) & isAvailable[]
src/hash.c
Calculates polynomial hash: sum(word[j]*26^j)%46106600 % 6999999. Direct array lookup.
int hashfunction2(char *word); // O(1) space, O(1) lookup
STEP 4 wordCheck(wordToGuess, input)
src/wordcheck.c
Fast-path equality comparator: returns 0 on invalid, 2 on exact match, 1 on partial match.
int wordCheck(char *word, char *guess);
STEP 5 wordColoring(wordToGuess, input, colors)
src/color.c
Pass 1: Tally target letters and mark exact matches ('G'). Pass 2: Mark misplaced ('Y') if remaining count > 0, else ('R').
void wordColoring(char *wordToGuess, char *input, char colors[]);
STEP 6 printColoredWord() & updateAtozcolors()
src/color.c
Wraps letters in ANSI escape codes (\033[1;32m etc.) and updates keyboard letter states.
void printColoredWord(char *guess, char *colors);

Function Details

Module: - Header: - Time: - Space: -

Input Buffer (char[1000])

""

Target Word (char[6])

*****

Polynomial Hash Index

-

Tries Left (5 - i)

6

Remaining Frequency Array (letterCount[26])

Native C Hosting Feasibility & WebAssembly Architecture

Static CDN vs POSIX PTY

Can we deploy and run native C applications on modern web platforms? Yes, using two primary production architectures:

1. Client-Side WebAssembly (Wasm) [Recommended for Static CDN]

Standard C source code compiles directly into a standalone WebAssembly (.wasm) binary using Emscripten or Clang with zero external libraries:

emcc wordle.c src/randomindex.c src/wordcheck.c src/hash.c src/color.c \ -Iinclude -s WASM=1 -o wordle.wasm

Advantages: $0 hosting cost. Executes directly inside the client's browser WebAssembly runtime with sandbox security, instant startup (< 1ms), and zero server containers.

2. Server-Side Native Container + PTY [Authentic POSIX Terminal]

For a pure OS-level terminal execution model, the standard GCC binary runs inside a lightweight Linux container:

gcc -O3 wordle.c src/randomindex.c src/wordcheck.c src/hash.c src/color.c \ -Iinclude -o wordle -lm && strip wordle

Advantages: Runs the authentic compiled ELF binary. Terminal I/O attaches to a pseudo-terminal daemon (node-pty or ttyd) streaming raw ANSI sequences over WebSockets to xterm.js.