Last active
June 1, 2022 00:55
-
-
Save keith-ratcliffe/7efb983df84e296460dba09191a198ab to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<script type="text/javascript"> | |
const answers = []; | |
const url = "https://gist.githubusercontent.com/cfreshman/a7b776506c73284511034e63af1017ee/raw/845966807347a7b857d53294525263408be967ce/wordle-nyt-answers-alphabetical.txt" | |
fetch(url) | |
.then((response) => response.text()) | |
.then((textString) => { | |
const rows = textString.split('\n'); | |
for (row of rows) { | |
answers.push(row); | |
} | |
}) | |
.catch(function(error) { | |
console.log(error); | |
}); | |
const blacks = []; | |
function doAddBlack() { | |
var newBlack = document.getElementById("blackInput").value.trim().toLowerCase(); | |
blacks.push(newBlack); | |
document.getElementById("blacksText").innerHTML = blacks.toString().toUpperCase(); | |
document.getElementById("blackInput").value = ""; | |
} | |
const yellows = []; | |
function doAddYellow() { | |
var newYellow = document.getElementById("yellowInput").value.trim().toLowerCase(); | |
yellows.push(newYellow); | |
document.getElementById("yellowsText").innerHTML = yellows.toString().toUpperCase(); | |
document.getElementById("yellowInput").value = ""; | |
} | |
const greens = []; | |
function doAddGreen() { | |
var newGreen = document.getElementById("greenInput").value.trim().toLowerCase(); | |
greens.push(newGreen); | |
document.getElementById("greenText").innerHTML = greens.toString().toUpperCase(); | |
document.getElementById("greenInput").value = ""; | |
} | |
function doGuess() { | |
var guesses = answers.filter(doFilter); | |
document.getElementById("guessesText").innerHTML = guesses.toString().replace(/,/g, "<br />").toUpperCase(); | |
} | |
function doFilter(item) { | |
for (var i = 0; i < blacks.length; i++) { | |
if (item.includes(blacks[i])) { | |
return false; | |
} | |
} | |
for (var i = 0; i < yellows.length; i++) { | |
const valPos = yellows[i].split(":"); | |
var val = valPos[0]; | |
var pos = valPos[1]; | |
if (item.charAt(pos - 1) == val || !item.includes(val)) { | |
return false; | |
} | |
} | |
for (var i = 0; i < greens.length; i++) { | |
const valPos = greens[i].split(":"); | |
var val = valPos[0]; | |
var pos = valPos[1]; | |
if (item.charAt(pos - 1) != val) { | |
return false; | |
} | |
} | |
return true; | |
} | |
</script> | |
<meta charset="UTF-8"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>NYT Wordle Guesser</title> | |
</head> | |
<body> | |
<h2>Tell me what you know:</h2> | |
<input id="blackInput" type="text"> | |
<button id="addBlackBtn" onclick="doAddBlack()">Add Black Letter</button> | |
<p id="blacksText"></p> | |
<br /> | |
<input id="yellowInput" type="text"> | |
<button id="addYellowBtn" onclick="doAddYellow()">Add Yellow "Letter:Position"</button> | |
<p id="yellowsText"></p> | |
<br /> | |
<input id="greenInput" type="text"> | |
<button id="addGreenBtn" onclick="doAddGreen()">Add Green "Letter:Position"</button> | |
<p id="greenText"></p> | |
<button id="guessBtn" onclick="doGuess()">Get some guesses</button> | |
<h2>Here are some guesses:</h2> | |
<p id="guessesText"></p> | |
<br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.githubusercontent.com/cfreshman/a7b776506c73284511034e63af1017ee/raw/845966807347a7b857d53294525263408be967ce/wordle-nyt-answers-alphabetical.txt