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