Last active
February 7, 2022 21:24
-
-
Save bgreenlee/62a4f29003dedcd66d018d57a60754bd to your computer and use it in GitHub Desktop.
Wordle "Solver"
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
#!/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