Skip to content

Instantly share code, notes, and snippets.

@bgreenlee
Last active February 7, 2022 21:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgreenlee/62a4f29003dedcd66d018d57a60754bd to your computer and use it in GitHub Desktop.
Save bgreenlee/62a4f29003dedcd66d018d57a60754bd to your computer and use it in GitHub Desktop.
Wordle "Solver"
#!/usr/bin/env python3
from datetime import datetime
import urllib.request
import re
# grab the word list
words_url = 'https://www.powerlanguage.co.uk/wordle/main.c1506a22.js'
req = urllib.request.Request(words_url, data=None,
headers={
'User-Agent': 'Wordle "Solver" 1.0'
}
)
f = urllib.request.urlopen(req)
raw_words = f.read().decode('utf-8')
m = re.search(r'var La=\[(.*?)\]', raw_words)
words = m.group(1).replace('"',"").split(",")
# calculate number of days since the Wordle epoch
epoch = datetime(2021,6,19,0,0,0,0)
today = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
days_since_epoch = (today - epoch).days
print(words[days_since_epoch % len(words)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment