Add files via upload

This commit is contained in:
Peter Norvig
2021-04-07 13:39:38 -07:00
committed by GitHub
parent 3242eccf6a
commit fa391d6f92
2 changed files with 569 additions and 554 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -361,20 +361,20 @@
{
"data": {
"text/plain": [
"[Honeycomb('ACEIORT', 'A'),\n",
" Honeycomb('ACEIORT', 'C'),\n",
" Honeycomb('ACEIORT', 'E'),\n",
" Honeycomb('ACEIORT', 'I'),\n",
" Honeycomb('ACEIORT', 'O'),\n",
" Honeycomb('ACEIORT', 'R'),\n",
" Honeycomb('ACEIORT', 'T'),\n",
" Honeycomb('AEGLMPX', 'A'),\n",
"[Honeycomb('AEGLMPX', 'A'),\n",
" Honeycomb('AEGLMPX', 'E'),\n",
" Honeycomb('AEGLMPX', 'G'),\n",
" Honeycomb('AEGLMPX', 'L'),\n",
" Honeycomb('AEGLMPX', 'M'),\n",
" Honeycomb('AEGLMPX', 'P'),\n",
" Honeycomb('AEGLMPX', 'X')]"
" Honeycomb('AEGLMPX', 'X'),\n",
" Honeycomb('ACEIORT', 'A'),\n",
" Honeycomb('ACEIORT', 'C'),\n",
" Honeycomb('ACEIORT', 'E'),\n",
" Honeycomb('ACEIORT', 'I'),\n",
" Honeycomb('ACEIORT', 'O'),\n",
" Honeycomb('ACEIORT', 'R'),\n",
" Honeycomb('ACEIORT', 'T')]"
]
},
"execution_count": 13,
@@ -541,8 +541,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 9.34 ms, sys: 31 µs, total: 9.37 ms\n",
"Wall time: 9.36 ms\n"
"CPU times: user 9.35 ms, sys: 82 µs, total: 9.43 ms\n",
"Wall time: 9.42 ms\n"
]
},
{
@@ -762,8 +762,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 1.71 s, sys: 1.2 ms, total: 1.71 s\n",
"Wall time: 1.71 s\n"
"CPU times: user 1.75 s, sys: 2.03 ms, total: 1.75 s\n",
"Wall time: 1.75 s\n"
]
}
],
@@ -877,8 +877,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 393 ms, sys: 1.31 ms, total: 395 ms\n",
"Wall time: 394 ms\n"
"CPU times: user 382 ms, sys: 864 µs, total: 383 ms\n",
"Wall time: 383 ms\n"
]
},
{
@@ -1371,10 +1371,10 @@
" \"\"\"The pareto frontier that minimizes word counts while maximizing points.\n",
" Returns a list of (wcount, points, honeycomb, points/wcount) entries\n",
" such that there is no other entry that has fewer words and more points.\"\"\"\n",
" return [(w, p, h, round(p/w, 2))\n",
" for w, (p, h) in sorted(table.items())\n",
" return sorted((w, p, h, round(p/w, 2))\n",
" for w, (p, h) in table.items()\n",
" if not any(h2 != h and w2 <= w and p2 >= p\n",
" for w2, (p2, h2) in table.items())]"
" for w2, (p2, h2) in table.items()))"
]
},
{
@@ -1402,13 +1402,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"So there are 108 (out of 55,902) honeycombs on the Pareto frontier. We can see the first ten (sorted by word count), and every tenth one after that:"
"So there are 108 (out of 55,902) honeycombs on the Pareto frontier. Here they are:"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
@@ -1422,7 +1424,105 @@
" (7, 62, Honeycomb('BGILNOX', 'X'), 8.86),\n",
" (8, 67, Honeycomb('DGINOXZ', 'X'), 8.38),\n",
" (9, 70, Honeycomb('EFNQRTU', 'Q'), 7.78),\n",
" (10, 84, Honeycomb('CENOQRU', 'Q'), 8.4)]"
" (10, 84, Honeycomb('CENOQRU', 'Q'), 8.4),\n",
" (11, 86, Honeycomb('GINOTUV', 'V'), 7.82),\n",
" (12, 100, Honeycomb('GILMNUZ', 'Z'), 8.33),\n",
" (13, 108, Honeycomb('GINOQTU', 'Q'), 8.31),\n",
" (14, 113, Honeycomb('CINOTXY', 'X'), 8.07),\n",
" (15, 115, Honeycomb('DGINOXZ', 'Z'), 7.67),\n",
" (16, 116, Honeycomb('DEIOPXZ', 'Z'), 7.25),\n",
" (17, 124, Honeycomb('CGINOUV', 'V'), 7.29),\n",
" (18, 136, Honeycomb('GHORTUW', 'W'), 7.56),\n",
" (19, 157, Honeycomb('DEIORXZ', 'X'), 8.26),\n",
" (22, 172, Honeycomb('DEGINPZ', 'Z'), 7.82),\n",
" (23, 184, Honeycomb('ACELQRU', 'Q'), 8.0),\n",
" (25, 189, Honeycomb('DELOPRX', 'X'), 7.56),\n",
" (26, 198, Honeycomb('AILNOTZ', 'Z'), 7.62),\n",
" (28, 224, Honeycomb('DEGINRZ', 'Z'), 8.0),\n",
" (33, 238, Honeycomb('DEIORXZ', 'Z'), 7.21),\n",
" (37, 243, Honeycomb('CGILNYZ', 'G'), 6.57),\n",
" (38, 275, Honeycomb('AGINOTZ', 'Z'), 7.24),\n",
" (41, 279, Honeycomb('CFGHILN', 'G'), 6.8),\n",
" (43, 324, Honeycomb('ACGINTV', 'V'), 7.53),\n",
" (45, 374, Honeycomb('ACINOTV', 'V'), 8.31),\n",
" (55, 385, Honeycomb('ACINOTU', 'U'), 7.0),\n",
" (59, 392, Honeycomb('GHINOTU', 'U'), 6.64),\n",
" (60, 396, Honeycomb('ACGILNZ', 'C'), 6.6),\n",
" (61, 404, Honeycomb('CGHINTW', 'G'), 6.62),\n",
" (62, 424, Honeycomb('CGHINRU', 'G'), 6.84),\n",
" (63, 426, Honeycomb('GINOPRU', 'U'), 6.76),\n",
" (65, 470, Honeycomb('CEINOTV', 'V'), 7.23),\n",
" (69, 485, Honeycomb('ACGINTV', 'C'), 7.03),\n",
" (70, 493, Honeycomb('CEGILNR', 'C'), 7.04),\n",
" (72, 495, Honeycomb('ACGHINR', 'H'), 6.88),\n",
" (73, 496, Honeycomb('CENORTV', 'V'), 6.79),\n",
" (74, 526, Honeycomb('ACILRTU', 'U'), 7.11),\n",
" (79, 530, Honeycomb('FGHILNT', 'G'), 6.71),\n",
" (81, 537, Honeycomb('BEFGINT', 'G'), 6.63),\n",
" (83, 552, Honeycomb('EGIMNPT', 'G'), 6.65),\n",
" (84, 571, Honeycomb('ACGIKNT', 'G'), 6.8),\n",
" (86, 606, Honeycomb('ACGINTV', 'G'), 7.05),\n",
" (89, 615, Honeycomb('ACILNTY', 'Y'), 6.91),\n",
" (92, 617, Honeycomb('CGINOTU', 'G'), 6.71),\n",
" (94, 646, Honeycomb('DELOPRV', 'V'), 6.87),\n",
" (98, 651, Honeycomb('FGILNPU', 'N'), 6.64),\n",
" (99, 674, Honeycomb('ACGINTV', 'T'), 6.81),\n",
" (102, 739, Honeycomb('GINORTU', 'U'), 7.25),\n",
" (110, 746, Honeycomb('CEGILNT', 'G'), 6.78),\n",
" (111, 764, Honeycomb('ACGHINT', 'G'), 6.88),\n",
" (113, 803, Honeycomb('CEGINOT', 'G'), 7.11),\n",
" (120, 823, Honeycomb('ACILRTU', 'C'), 6.86),\n",
" (122, 860, Honeycomb('ACGILNT', 'C'), 7.05),\n",
" (126, 879, Honeycomb('CEGINOT', 'C'), 6.98),\n",
" (131, 882, Honeycomb('CEGINPR', 'G'), 6.73),\n",
" (135, 929, Honeycomb('CEGILNR', 'G'), 6.88),\n",
" (136, 955, Honeycomb('EGINRTV', 'V'), 7.02),\n",
" (140, 994, Honeycomb('CENORTU', 'U'), 7.1),\n",
" (149, 1064, Honeycomb('CEGINRT', 'G'), 7.14),\n",
" (152, 1065, Honeycomb('ACGINOT', 'G'), 7.01),\n",
" (159, 1118, Honeycomb('ACGILNT', 'G'), 7.03),\n",
" (162, 1159, Honeycomb('CENORTU', 'C'), 7.15),\n",
" (166, 1161, Honeycomb('EFGILNR', 'G'), 6.99),\n",
" (169, 1187, Honeycomb('CDEINRT', 'C'), 7.02),\n",
" (172, 1199, Honeycomb('EGINRTW', 'G'), 6.97),\n",
" (180, 1207, Honeycomb('BEGINRT', 'G'), 6.71),\n",
" (181, 1288, Honeycomb('EFGINRT', 'G'), 7.12),\n",
" (183, 1323, Honeycomb('EGINRTV', 'G'), 7.23),\n",
" (188, 1367, Honeycomb('EGIMNRT', 'G'), 7.27),\n",
" (202, 1405, Honeycomb('EGINRTU', 'G'), 6.96),\n",
" (212, 1430, Honeycomb('EGINRTV', 'T'), 6.75),\n",
" (214, 1431, Honeycomb('DEGINRV', 'G'), 6.69),\n",
" (219, 1448, Honeycomb('ACINORT', 'C'), 6.61),\n",
" (221, 1472, Honeycomb('ACILNOT', 'L'), 6.66),\n",
" (223, 1562, Honeycomb('DEFGINR', 'G'), 7.0),\n",
" (230, 1566, Honeycomb('BDEGINR', 'G'), 6.81),\n",
" (231, 1598, Honeycomb('ACGINOT', 'I'), 6.92),\n",
" (234, 1685, Honeycomb('EGILNRT', 'G'), 7.2),\n",
" (238, 1691, Honeycomb('ACILNOT', 'C'), 7.11),\n",
" (244, 1737, Honeycomb('CEINORT', 'C'), 7.12),\n",
" (251, 1774, Honeycomb('ACILNOT', 'I'), 7.07),\n",
" (254, 1787, Honeycomb('ACILNOT', 'N'), 7.04),\n",
" (264, 1788, Honeycomb('DEGILNR', 'N'), 6.77),\n",
" (265, 1830, Honeycomb('DEGINRT', 'G'), 6.91),\n",
" (269, 1847, Honeycomb('CEINORT', 'I'), 6.87),\n",
" (275, 1856, Honeycomb('EGILNRT', 'R'), 6.75),\n",
" (277, 1882, Honeycomb('ACILNOT', 'A'), 6.79),\n",
" (280, 1893, Honeycomb('DEGILNR', 'G'), 6.76),\n",
" (282, 1968, Honeycomb('AGINORT', 'I'), 6.98),\n",
" (283, 1982, Honeycomb('ACEINRT', 'C'), 7.0),\n",
" (288, 2011, Honeycomb('AEGILNT', 'G'), 6.98),\n",
" (297, 2038, Honeycomb('CEINORT', 'N'), 6.86),\n",
" (312, 2117, Honeycomb('AGINORT', 'N'), 6.79),\n",
" (320, 2193, Honeycomb('AEGILNT', 'I'), 6.85),\n",
" (330, 2311, Honeycomb('ACEINRT', 'I'), 7.0),\n",
" (354, 2414, Honeycomb('ACEINRT', 'N'), 6.82),\n",
" (370, 2575, Honeycomb('ADEGINR', 'I'), 6.96),\n",
" (397, 2626, Honeycomb('ADEGINR', 'D'), 6.61),\n",
" (403, 3095, Honeycomb('AEGINRT', 'G'), 7.68),\n",
" (442, 3406, Honeycomb('AEGINRT', 'I'), 7.71),\n",
" (466, 3421, Honeycomb('AEGINRT', 'T'), 7.34),\n",
" (512, 3782, Honeycomb('AEGINRT', 'N'), 7.39),\n",
" (537, 3898, Honeycomb('AEGINRT', 'R'), 7.26)]"
]
},
"execution_count": 44,
@@ -1431,36 +1531,7 @@
}
],
"source": [
"ph[:10] # (word count, points, honeycomb, points/wcount) "
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(11, 86, Honeycomb('GINOTUV', 'V'), 7.82),\n",
" (23, 184, Honeycomb('ACELQRU', 'Q'), 8.0),\n",
" (55, 385, Honeycomb('ACINOTU', 'U'), 7.0),\n",
" (73, 496, Honeycomb('CENORTV', 'V'), 6.79),\n",
" (98, 651, Honeycomb('FGILNPU', 'N'), 6.64),\n",
" (135, 929, Honeycomb('CEGILNR', 'G'), 6.88),\n",
" (180, 1207, Honeycomb('BEGINRT', 'G'), 6.71),\n",
" (230, 1566, Honeycomb('BDEGINR', 'G'), 6.81),\n",
" (275, 1856, Honeycomb('EGILNRT', 'R'), 6.75),\n",
" (354, 2414, Honeycomb('ACEINRT', 'N'), 6.82)]"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ph[10::10]"
"ph # (word count, points, honeycomb, points/wcount) "
]
},
{
@@ -1472,7 +1543,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 45,
"metadata": {},
"outputs": [
{
@@ -1494,7 +1565,7 @@
"def plot(xlabel, X, ylabel, Y): \n",
" plt.plot(X, Y, '.'); plt.xlabel(xlabel); plt.ylabel(ylabel); plt.grid(True)\n",
" \n",
"plot('Word count', W, 'Points', P, )"
"plot('Word count', W, 'Points', P)"
]
},
{
@@ -1506,7 +1577,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 46,
"metadata": {},
"outputs": [
{
@@ -1530,12 +1601,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see all the Pareto optimal honeycombs that score more than, say, 7.6 points per word:"
"So the highest points per word are for honeycombs with very few words. We can see all the Pareto optimal honeycombs that score more than, say, 7.6 points per word:"
]
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 47,
"metadata": {},
"outputs": [
{
@@ -1566,7 +1637,7 @@
" (442, 3406, Honeycomb('AEGINRT', 'I'), 7.71)]"
]
},
"execution_count": 48,
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
@@ -1579,43 +1650,19 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The last few honeycombs on the right-hand side all rise above the average points/word. We can see that they are all variants of the highest-scoring honeycomb, but with different centers:"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(403, 3095, Honeycomb('AEGINRT', 'G'), 7.68),\n",
" (442, 3406, Honeycomb('AEGINRT', 'I'), 7.71),\n",
" (466, 3421, Honeycomb('AEGINRT', 'T'), 7.34),\n",
" (512, 3782, Honeycomb('AEGINRT', 'N'), 7.39),\n",
" (537, 3898, Honeycomb('AEGINRT', 'R'), 7.26)]"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ph[-5:]"
"The last two of these represent our old optimal honeycomb, with two different centers."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here are reports on what I think are the most interesting low-word-count, higher-score honeycombs. I would have scored zero on the first one, and probably not much better on the second."
"Here are reports on what I think are the most interesting low-word-count, higher-score honeycombs. I would not have been able to find any words at all for the first one, I think:"
]
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 48,
"metadata": {},
"outputs": [
{
@@ -1638,7 +1685,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 49,
"metadata": {},
"outputs": [
{
@@ -1670,7 +1717,7 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 50,
"metadata": {},
"outputs": [
{
@@ -1710,7 +1757,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 51,
"metadata": {},
"outputs": [
{
@@ -1766,7 +1813,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 52,
"metadata": {},
"outputs": [
{
@@ -1775,7 +1822,7 @@
"(98141, 44585)"
]
},
"execution_count": 54,
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
@@ -1796,7 +1843,7 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": 53,
"metadata": {},
"outputs": [
{