Skip to content

Instantly share code, notes, and snippets.

@kevdougful
Last active February 5, 2022 18:56
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 kevdougful/4b4351ec14094e12d9b364e183b2614a to your computer and use it in GitHub Desktop.
Save kevdougful/4b4351ec14094e12d9b364e183b2614a to your computer and use it in GitHub Desktop.
Wordle Letter Analysis
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"import httpx\n",
"import string"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"wordlist_url=\"https://gist.githubusercontent.com/cfreshman/a03ef2cba789d8cf00c08f767e0fad7b/raw/5d752e5f0702da315298a6bb5a771586d6ff445c/wordle-answers-alphabetical.txt\"\n",
"req = httpx.get(wordlist_url)\n",
"wordlist = req.text.split(\"\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"ranks = {l: 0 for l in string.ascii_lowercase}\n",
"for word in wordlist:\n",
" for letter in list(word):\n",
" ranks[letter] += 1\n",
"ranks = {k: v for k, v in sorted(ranks.items(), key=lambda item: item[1], reverse=True)}"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'e': 1233,\n",
" 'a': 979,\n",
" 'r': 899,\n",
" 'o': 754,\n",
" 't': 729,\n",
" 'l': 719,\n",
" 'i': 671,\n",
" 's': 669,\n",
" 'n': 575,\n",
" 'c': 477,\n",
" 'u': 467,\n",
" 'y': 425,\n",
" 'd': 393,\n",
" 'h': 389,\n",
" 'p': 367,\n",
" 'm': 316,\n",
" 'g': 311,\n",
" 'b': 281,\n",
" 'f': 230,\n",
" 'k': 210,\n",
" 'w': 195,\n",
" 'v': 153,\n",
" 'z': 40,\n",
" 'x': 37,\n",
" 'q': 29,\n",
" 'j': 27}"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ranks"
]
}
],
"metadata": {
"interpreter": {
"hash": "98c9d943fe1a85dfa99c6431b9468b5592dc4a68f3752121c24412b919211663"
},
"kernelspec": {
"display_name": "Python 3.9.2 ('venv': venv)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment