Add files via upload

This commit is contained in:
Peter Norvig 2026-03-12 14:18:58 -07:00 committed by GitHub
parent da9e5e55a6
commit d64e1004d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 831 additions and 633 deletions

File diff suppressed because it is too large Load Diff

View File

@ -298,10 +298,10 @@
{
"data": {
"text/plain": [
"['000000000000000000000000000000000000000000000000000000000000',\n",
" '000000000000000000000000000000000000000000000000000000000001',\n",
" '863811000557423423230896109004106619977392256259918212890625',\n",
" '136188999442576576769103890995893380022607743740081787109376']"
"['0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\n",
" '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001',\n",
" '3953007319108169802938509890062166509580863811000557423423230896109004106619977392256259918212890625',\n",
" '6046992680891830197061490109937833490419136188999442576576769103890995893380022607743740081787109376']"
]
},
"execution_count": 8,
@ -310,31 +310,7 @@
}
],
"source": [
"stubborn_endings(60)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "73491ea5-a4c8-4221-8fc7-d6ce44d17bb4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\n",
" '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001',\n",
" '055462996814764263903953007319108169802938509890062166509580863811000557423423230896109004106619977392256259918212890625',\n",
" '944537003185235736096046992680891830197061490109937833490419136188999442576576769103890995893380022607743740081787109376']"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stubborn_endings(120)"
"stubborn_endings(100)"
]
},
{
@ -344,33 +320,24 @@
"source": [
"This leads to a few new questions.\n",
"\n",
"## Can each stubborn ending be extended exactly one way?\n",
"## Can each stubborn ending always be extended exactly one way?\n",
"\n",
"We know that each stubborn ending of length *d* has to build on the endings of length *d* - 1, and so far, there has always been exactly one way (out of the ten possible digits) to extend each of the length *d* - 1 endings. Will that always be true? Might there be a case where two digits work with one of the endings, or no digits?\n",
"\n",
"I can show that for all lengths *d* up to 2000, the result of `stubborn_endings(d)` is always four strings that end with '0', '1', '5', and '6' in that order:"
"There are four stubborn endings of length 1: '0', '1', '5', and '6'. So far, every time we try, each of the four can be extended from length *d* to length *d*+1 in exactly one way. Will that always be the case? I leave it up to you to provide a proof, but I can show that it is true for every *d* up to 2000:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"id": "654d53af-e58f-4ed2-874b-c4573f3a9a7a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Counter({('0', '1', '5', '6'): 2000})"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"Counter(tuple(ending[-1] for ending in stubborn_endings(d))\n",
" for d in range(1, 2001))"
"def last_digits(endings) -> list[str]: \n",
" \"\"\"A list of the last digits of these endings.\"\"\"\n",
" return [e[-1] for e in endings]\n",
" \n",
"for d in range(1, 2000):\n",
" assert last_digits(stubborn_endings(d)) == ['0', '1', '5', '6']"
]
},
{
@ -378,8 +345,6 @@
"id": "537556a3-d570-4a50-93bf-9632b40f9b47",
"metadata": {},
"source": [
"I leave it up to the reader to find a proof ofr numbers beyond 2000.\n",
"\n",
"## What digits are used to extend each ending?\n",
"\n",
"I don't have a theory of which digit is used to extend each stubborn ending, but I can count:"
@ -387,7 +352,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "4dbd7ace-8b41-4ea7-b71f-8f7e318243e1",
"metadata": {},
"outputs": [
@ -418,7 +383,7 @@
" '6': 173})}"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@ -426,7 +391,7 @@
"source": [
"from collections import Counter\n",
"\n",
"{e[-1]: Counter(e[:-1]) for e in stubborn_endings(2000)}"
"{end: Counter(start) for (*start, end) in stubborn_endings(2000)}"
]
},
{

File diff suppressed because one or more lines are too long