Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
Why is my Wordle solver failing when there are repeated characters?

For context Wordle is game where you have to decipher a 5 letter word in 6 or less guesses based on certain hints. The hints you get are as follows:

  1. If a character is coloured black there are no characters that match that character in the target word.
  2. If a character is coloured orange there is a character that matches that character in the target word but it is in a different position.
  3. If a character is coloured green the position and the character are a match.

I am making a wordle solver program that takes in an array of word attempts and eliminates them from a list of the possible words.

I feel that the best algorithm to solve this problem is a black list where a word that breaks one of the rules is eliminated from the array. But if there is a better alternative I am open to suggestion.


const text =
[
  [
    ["N","black"],["i","black"],["g","black"],
    ["h","black"],["t","green"]
  ],
  [
    ["b","black"],["e","black"],["l","orange"],
    ["o","orange"],["w","black"]
  ]
]

const words = "dozen,brave,apple,climb,outer,pitch,ruler,holds,fixed,costs,calls, ...etc"

const solver = (text: any) => {
    this.resultingWords = words.split(",").filter(word => {
      word = word.toUpperCase()
      for (var i = 0; i < text.length; i++) {
        for (var j = 0; j < 5; j++) {
          let currentText = text[i][j]
          currentText[0] = currentText[0].toUpperCase()
          if (currentText[0] == '') { continue }
          if (currentText[1] == "green" && (word[j] != currentText[0])) {
            return false
          }
          if (currentText[1] == "black" && word.includes(currentText[0])) {
            return false;
          }
          if (currentText[1] == "orange" &&
          (word[j] == currentText[0] || !word.includes(currentText[0]))) {
            return false
          }
        }
      }
      return true
    })
  }

The issue I am having is if a word has multiple of the same letter and one of them is a green or orange match but the other is black. I get no results because of the way I've written my algorithm.

What would be the way to correctly solve this problem?

Is a black list style of filtering the best solution? (as opposed to white list).

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are building a list of candidates, what is a good start I think. It doesn't really matter whether you white- or blacklist the result is the list of candidates. The only concern is that you could get the solution faster or more reliably by guessing words that are not on the candidates list. Why? Because that way you can introduce more new letters at once to check if the word contains them. Maybe a mix between the two strategies is best, hard to tell without testing it first.

  • "green" is OK.
  • "black" needs to count the number of non-black appearances of the letter in the guess and all words that not contain that exact amount of that letter can be eliminated (and also those that have the letter at a black position).
  • "orange" is OK but can be improved: you can count the number of non-black appearances of the letter in the guess and eliminate all words that contain the letter fewer times (checking for minimal appearance and not just at least once) and also what you already have applies: the letter cannot be at an orange position.

There are a lot of ideas for improvements. First I would create the filter before going through the words. Using similar logic as above you would get a collection of four different rule types: A letter has to be or cannot be at a specific position or a letter has to appear exactly (possibly 0) or at least a specific number of times. Then you go through the words and filter using those rules. Otherwise some work might be done multiple times. It is easiest to create such a filter by collecting the same letters in the guess first. If there is an exact number of appearence rule then you can obviously drop a minimal number of appearance rule for the same letter.

To guess the word fast I would create an evaluation function to find the most promising next guess among the candidates. Possible values to score:

  • How many new letters are introduced (letters that were not guessed yet).
  • Also the probabilites of the new letters could be taken into account. E.g. how likely is it that a word contains a specific letter. Or even look at correlations between letters: like if I have a Q then I probably also have a U or if the last letter is D then the likelyhood of the 2nd last being E is very high.
  • You could even go through all the possible answers for every candidate and see which guess eliminates the most words on average or something similar. Although this probably takes too long unless somehow approximated.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda