DEV Community

justin
justin

Posted on

Word Ladder Games: Compute Shortest Paths at Build Time

Feetle - a small word ladder game does not need a backend for every move. Treat each valid word as a graph node and connect words that differ in exactly one position. Run breadth first search from the target during the build to calculate shortest distances. In the browser, validate moves against the bundled dictionary and compare completed paths with those distances. Rebuild the graph whenever the dictionary changes: removing one word can change the shortest route or disconnect a starting word entirely. Astro can serve static pages while React handles interaction in the browser.

Top comments (0)