Last active
January 19, 2022 00:51
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
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
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.