Giter Club home page Giter Club logo

wordle-finder's Introduction

Five by Five word finder

Solution to a random puzzle I saw online and got nerdsniped by through Twitter.

Problem statement:

Given a list of words, find all combinations of five five-letter words, that have no repeated letters, i.e. use 25 letters from the alphabet.

Also for some reason we also have to dedupe words with the same set of letters from the wordlist.

Source video for the problem:

 Can you find: five five-letter words with twenty-five unique letters?

Other solution that I used for comparison: https://github.com/jekstrand/wordle-finder

Insights of solution

The key insight I used is that this can be done by dynamic programming, where the state space is the bitset of letters used (which has 1 << 26 values), the value per state is whether there is a solution of five-letter words with no repetition (of course not necessarily five words if less bits are set).

So for the computation we can do the following:

  1. State 0 obviously has a solution of zero words.
  2. For other states, there is a solution if there is a word that is a subset of the state, and the state minus the letters from the word also has a solution. This can be found by iterating over the word list.

This gives an algorithm where the inner loop has less than (1u << 26) * wordlist.size() iterations. We can then add the usual accounting to extract the actual solutions from a dynamic programming algorithm.

This gives me a runtime of less than two seconds for the words_alpha.txt.

Building & Running

You can build with a standard

   make

and then run with

   ./wordle-finder third_party/english-words/words_alpha.txt

for a large word list. For the wordle list you have to concatenate the answers and guesses.

wordle-finder's People

Contributors

bnieuwenhuizen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.