Skip to content

Instantly share code, notes, and snippets.

@frankus
Last active January 19, 2022 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankus/2cd2652a1924fcf4da91f4f94f4c7bcc to your computer and use it in GitHub Desktop.
Save frankus/2cd2652a1924fcf4da91f4f94f4c7bcc to your computer and use it in GitHub Desktop.
Attempt to find the best starting words in Wordle (maximize chance of getting a green letter)
cares
saree
sores
seres
bares
soree
soras
cores
sires
sared
ceres
saris
seats
carts
coats
bores
sorts
sanes
caaed
pares
boats
carte
cared
cires
sones
unfix
upbye
xylyl
kudzu
undug
izzat
embow
hajji
exurb
inbox
imshi
infix
idyll
ichor
upbow
ogham
qajaq
oshac
abuzz
zebub
usque
oxbow
ethyl
ewhow
enzym
import UIKit
let fiveLetterWords = <#insert wordle word list here#>
var letterFrequency: [[String:Int]] = Array(repeating: [:], count: 5)
for word in fiveLetterWords {
for (index, character) in word.enumerated() {
if letterFrequency[index][String(character)] == nil {
letterFrequency[index][String(character)] = 1
} else {
letterFrequency[index][String(character)]! += 1
}
}
}
let sortedFreqs = letterFrequency.map { freq in
freq.sorted { $0.1 > $1.1 }.map { $0.key }
}
var wordScores = [String:Int]()
for word in fiveLetterWords {
var score = 0
for (index, character) in word.enumerated() {
score += sortedFreqs[index].firstIndex(of: String(character)) ?? 26
}
wordScores[String(word)] = score
}
let bestWords = wordScores.sorted { $0.1 < $1.1 }.map { $0.key }
for word in bestWords {
print(word)
}
@frankus
Copy link
Author

frankus commented Jan 18, 2022

Updated to use just the words from the wordle word list, not including the whole list for fair use and general "don't be a douche" reasons, but you can view source and grab it yourself.

The "Worst" list is just a tail of the bottom of the list, so the last entry is worst.

@frankus
Copy link
Author

frankus commented Jan 19, 2022

Updated using the union of the "answers" list and the "rest of the words that aren't answers" list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment