Add files via upload
This commit is contained in:
parent
68d9313ddc
commit
8831dc1e60
@ -128,10 +128,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'CACCIATORE': 17,\n",
|
||||
" 'GLAM': 1,\n",
|
||||
" 'GAME': 1,\n",
|
||||
"{'GAME': 1,\n",
|
||||
" 'CACCIATORE': 17,\n",
|
||||
" 'AMALGAM': 7,\n",
|
||||
" 'GLAM': 1,\n",
|
||||
" 'EROTICA': 14,\n",
|
||||
" 'MEGAPLEX': 15}"
|
||||
]
|
||||
@ -173,10 +173,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'CACCIATORE': 'ACEIORT',\n",
|
||||
" 'GLAM': 'AGLM',\n",
|
||||
" 'GAME': 'AEGM',\n",
|
||||
"{'GAME': 'AEGM',\n",
|
||||
" 'CACCIATORE': 'ACEIORT',\n",
|
||||
" 'AMALGAM': 'AGLM',\n",
|
||||
" 'GLAM': 'AGLM',\n",
|
||||
" 'EROTICA': 'ACEIORT',\n",
|
||||
" 'MEGAPLEX': 'AEGLMPX'}"
|
||||
]
|
||||
@ -246,16 +246,16 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['LINKWORK',\n",
|
||||
" 'IMPURITY',\n",
|
||||
" 'CROWBERRY',\n",
|
||||
" 'ENDAMOEBA',\n",
|
||||
" 'ADUMBRAL',\n",
|
||||
" 'AGENTIAL',\n",
|
||||
" 'PLIANCY',\n",
|
||||
" 'MENTIONING',\n",
|
||||
" 'INCARNADINE',\n",
|
||||
" 'UNMEWING']"
|
||||
"['MODIFIER',\n",
|
||||
" 'FLUORIC',\n",
|
||||
" 'PENTANOL',\n",
|
||||
" 'COMPLECT',\n",
|
||||
" 'COVERTURE',\n",
|
||||
" 'GNOTOBIOTIC',\n",
|
||||
" 'INTREATED',\n",
|
||||
" 'COMMUTATOR',\n",
|
||||
" 'PREPLANT',\n",
|
||||
" 'PRINTERY']"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
@ -392,8 +392,8 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"CPU times: user 10.3 ms, sys: 436 µs, total: 10.7 ms\n",
|
||||
"Wall time: 10.6 ms\n"
|
||||
"CPU times: user 9.86 ms, sys: 343 µs, total: 10.2 ms\n",
|
||||
"Wall time: 10 ms\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -444,7 +444,7 @@
|
||||
"\n",
|
||||
"def letter_subsets(honeycomb) -> list:\n",
|
||||
" \"\"\"All 64 subsets of the letters in the honeycomb that contain the center letter.\"\"\"\n",
|
||||
" letters, center = honeycomb\n",
|
||||
" (letters, center) = honeycomb\n",
|
||||
" return [''.join(subset) \n",
|
||||
" for n in range(1, 8) \n",
|
||||
" for subset in combinations(letters, n)\n",
|
||||
@ -555,10 +555,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'CACCIATORE': 17,\n",
|
||||
" 'GLAM': 1,\n",
|
||||
" 'GAME': 1,\n",
|
||||
"{'GAME': 1,\n",
|
||||
" 'CACCIATORE': 17,\n",
|
||||
" 'AMALGAM': 7,\n",
|
||||
" 'GLAM': 1,\n",
|
||||
" 'EROTICA': 14,\n",
|
||||
" 'MEGAPLEX': 15}"
|
||||
]
|
||||
@ -580,7 +580,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Counter({'ACEIORT': 31, 'AGLM': 8, 'AEGM': 1, 'AEGLMPX': 15})"
|
||||
"Counter({'AEGM': 1, 'ACEIORT': 31, 'AGLM': 8, 'AEGLMPX': 15})"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
@ -666,7 +666,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def best_honeycomb(words) -> tuple: \n",
|
||||
" \"\"\"Return (score, letters, center) for the honeycomb with highest score on these words.\"\"\"\n",
|
||||
" \"\"\"Return (score, honeycomb) for the honeycomb with highest score on these words.\"\"\"\n",
|
||||
" pts_table = points_table(words)\n",
|
||||
" pangrams = [s for s in pts_table if len(s) == 7]\n",
|
||||
" honeycombs = ((pangram, center) for pangram in pangrams for center in pangram)\n",
|
||||
@ -717,8 +717,8 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"CPU times: user 2.07 s, sys: 7.27 ms, total: 2.08 s\n",
|
||||
"Wall time: 2.09 s\n"
|
||||
"CPU times: user 2.04 s, sys: 7.02 ms, total: 2.05 s\n",
|
||||
"Wall time: 2.06 s\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -755,7 +755,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from textwrap import fill, wrap\n",
|
||||
"from textwrap import fill\n",
|
||||
"\n",
|
||||
"def report(words, honeycomb=None):\n",
|
||||
" \"\"\"Print stats and word scores for the given honeycomb (or for the best honeycomb\n",
|
||||
@ -763,19 +763,19 @@
|
||||
" optimal = (\"\" if honeycomb else \"optimal \")\n",
|
||||
" if not honeycomb:\n",
|
||||
" _, honeycomb = best_honeycomb(words)\n",
|
||||
" letters, center = honeycomb\n",
|
||||
" (letters, center) = honeycomb\n",
|
||||
" subsets = letter_subsets(honeycomb)\n",
|
||||
" bins = group_by(words, letterset)\n",
|
||||
" score = sum(word_score(w) for w in words if letterset(w) in subsets)\n",
|
||||
" N = sum(len(bins[s]) for s in subsets)\n",
|
||||
" print(f'For this list of {len(words):,d} words:\\n'\n",
|
||||
" f'The {optimal}honeycomb ({letters}, {center}) forms '\n",
|
||||
" f'{N} words for {score:,d} points.\\n')\n",
|
||||
" print(f'For this list of {len(words):,d} words:')\n",
|
||||
" print(f'The {optimal}honeycomb ({letters}, {center}) forms '\n",
|
||||
" f'{N} words for {score:,d} points.')\n",
|
||||
" print(f'Here are the words formed, with pangrams first:\\n')\n",
|
||||
" for s in sorted(subsets, key=lambda s: (-len(s), s)):\n",
|
||||
" if bins[s]:\n",
|
||||
" p = (' pangram' if len(s) == 7 else '')\n",
|
||||
" pts = sum(word_score(w) for w in bins[s])\n",
|
||||
" print(f'{s} forms {len(bins[s])}{p} words for {pts:,d} points:')\n",
|
||||
" print(f'{s} forms {len(bins[s])} words for {pts:,d} points:')\n",
|
||||
" words = [f'{w}({word_score(w)})' for w in sorted(bins[s])]\n",
|
||||
" print(fill(' '.join(words), width=80,\n",
|
||||
" initial_indent=' ', subsequent_indent=' '))\n",
|
||||
@ -799,8 +799,9 @@
|
||||
"text": [
|
||||
"For this list of 6 words:\n",
|
||||
"The honeycomb (AEGLMPX, G) forms 4 words for 24 points.\n",
|
||||
"Here are the words formed, with pangrams first:\n",
|
||||
"\n",
|
||||
"AEGLMPX forms 1 pangram words for 15 points:\n",
|
||||
"AEGLMPX forms 1 words for 15 points:\n",
|
||||
" MEGAPLEX(15)\n",
|
||||
"AEGM forms 1 words for 1 points:\n",
|
||||
" GAME(1)\n",
|
||||
@ -824,8 +825,9 @@
|
||||
"text": [
|
||||
"For this list of 6 words:\n",
|
||||
"The optimal honeycomb (ACEIORT, T) forms 2 words for 31 points.\n",
|
||||
"Here are the words formed, with pangrams first:\n",
|
||||
"\n",
|
||||
"ACEIORT forms 2 pangram words for 31 points:\n",
|
||||
"ACEIORT forms 2 words for 31 points:\n",
|
||||
" CACCIATORE(17) EROTICA(14)\n"
|
||||
]
|
||||
}
|
||||
@ -847,8 +849,9 @@
|
||||
"text": [
|
||||
"For this list of 44,585 words:\n",
|
||||
"The optimal honeycomb (AEGINRT, R) forms 537 words for 3,898 points.\n",
|
||||
"Here are the words formed, with pangrams first:\n",
|
||||
"\n",
|
||||
"AEGINRT forms 50 pangram words for 832 points:\n",
|
||||
"AEGINRT forms 50 words for 832 points:\n",
|
||||
" AERATING(15) AGGREGATING(18) ARGENTINE(16) ARGENTITE(16) ENTERTAINING(19)\n",
|
||||
" ENTRAINING(17) ENTREATING(17) GARNIERITE(17) GARTERING(16) GENERATING(17)\n",
|
||||
" GNATTIER(15) GRANITE(14) GRATINE(14) GRATINEE(15) GRATINEEING(18)\n",
|
||||
|
Loading…
Reference in New Issue
Block a user