projects
/
advent-of-code-15.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5a21949
)
Fixed typo
master
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Wed, 22 Jun 2022 10:34:53 +0000
(11:34 +0100)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Wed, 22 Jun 2022 10:34:53 +0000
(11:34 +0100)
advent19.ipynb
patch
|
blob
|
history
diff --git
a/advent19.ipynb
b/advent19.ipynb
index f0966902fe7d5c7d1ffc9ca72b38e6d0299fd790..2288bcc79a6bbe94420aeabfd99e6fc021022e6d 100644
(file)
--- a/
advent19.ipynb
+++ b/
advent19.ipynb
@@
-2,9
+2,9
@@
"cells": [
{
"cell_type": "code",
"cells": [
{
"cell_type": "code",
- "execution_count": 1
0
,
+ "execution_count": 1,
"metadata": {
"metadata": {
- "
collapsed": true
+ "
tags": []
},
"outputs": [],
"source": [
},
"outputs": [],
"source": [
@@
-15,14
+15,17
@@
"cell_type": "markdown",
"metadata": {},
"source": [
"cell_type": "markdown",
"metadata": {},
"source": [
- "#Part 1"
+ "#
Part 1"
]
},
{
"cell_type": "code",
]
},
{
"cell_type": "code",
- "execution_count":
1
,
+ "execution_count":
2
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-75,7
+78,7
@@
" 'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl']"
]
},
" 'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl']"
]
},
- "execution_count":
1
,
+ "execution_count":
2
,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"output_type": "execute_result"
}
@@
-87,9
+90,12
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
2
,
+ "execution_count":
3
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-140,7
+146,7
@@
" ['e', 'OMg']]"
]
},
" ['e', 'OMg']]"
]
},
- "execution_count":
2
,
+ "execution_count":
3
,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"output_type": "execute_result"
}
@@
-152,9
+158,12
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
8
,
+ "execution_count":
4
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-163,7
+172,7
@@
"'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl'"
]
},
"'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl'"
]
},
- "execution_count":
8
,
+ "execution_count":
4
,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"output_type": "execute_result"
}
@@
-177,7
+186,10
@@
"cell_type": "code",
"execution_count": 5,
"metadata": {
"cell_type": "code",
"execution_count": 5,
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-198,15
+210,18
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
18
,
+ "execution_count":
7
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [],
"source": [
"transformed = set([])\n",
"for r in rules:\n",
},
"outputs": [],
"source": [
"transformed = set([])\n",
"for r in rules:\n",
- " for m in re.finditer(r[0],
target
):\n",
+ " for m in re.finditer(r[0],
base
):\n",
" t = base[:m.start(0)] + r[1] + base[m.end(0):]\n",
" # print(t, m.start(0), m.end(0))\n",
" transformed.update([t])"
" t = base[:m.start(0)] + r[1] + base[m.end(0):]\n",
" # print(t, m.start(0), m.end(0))\n",
" transformed.update([t])"
@@
-214,9
+229,12
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
19
,
+ "execution_count":
8
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-225,7
+243,7
@@
"518"
]
},
"518"
]
},
- "execution_count":
19
,
+ "execution_count":
8
,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"output_type": "execute_result"
}
@@
-238,14
+256,14
@@
"cell_type": "markdown",
"metadata": {},
"source": [
"cell_type": "markdown",
"metadata": {},
"source": [
- "#Part 2"
+ "#
Part 2"
]
},
{
"cell_type": "code",
]
},
{
"cell_type": "code",
- "execution_count":
48
,
+ "execution_count":
9
,
"metadata": {
"metadata": {
- "
collapsed": true
+ "
tags": []
},
"outputs": [],
"source": [
},
"outputs": [],
"source": [
@@
-256,18
+274,21
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
76
,
+ "execution_count":
14
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [],
"source": [
"#This is infeasible\n",
"\n",
},
"outputs": [],
"source": [
"#This is infeasible\n",
"\n",
- "#agenda = [(base, 0)]\n",
- "#closed_set = set()\n",
+ "#
agenda = [(base, 0)]\n",
+ "#
closed_set = set()\n",
"\n",
"\n",
- "#while agenda[0][0] != 'e':\n",
+ "#
while agenda[0][0] != 'e':\n",
"# # print(len(agenda), len(agenda[0][0]))\n",
"# current_m, current_c = agenda[0]\n",
"# if current_m in closed_set:\n",
"# # print(len(agenda), len(agenda[0][0]))\n",
"# current_m, current_c = agenda[0]\n",
"# if current_m in closed_set:\n",
@@
-276,14
+297,17
@@
"# closed_set.update(current_m)\n",
"# new_molecules = [(reduced, current_c + 1) for r in rules for reduced in reductions(r, current_m)]\n",
"# agenda = agenda[1:] + new_molecules\n",
"# closed_set.update(current_m)\n",
"# new_molecules = [(reduced, current_c + 1) for r in rules for reduced in reductions(r, current_m)]\n",
"# agenda = agenda[1:] + new_molecules\n",
- "#agenda[0]"
+ "#
agenda[0]"
]
},
{
"cell_type": "code",
]
},
{
"cell_type": "code",
- "execution_count":
7
5,
+ "execution_count":
1
5,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
},
"outputs": [
{
@@
-292,7
+316,7
@@
"('e', 200)"
]
},
"('e', 200)"
]
},
- "execution_count":
7
5,
+ "execution_count":
1
5,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"output_type": "execute_result"
}
@@
-312,16
+336,19
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
73
,
+ "execution_count":
11
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "
1 loops, best of 3: 281 ms per loop
\n"
+ "
317 ms ± 18.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
\n"
]
}
],
]
}
],
@@
-341,16
+368,19
@@
},
{
"cell_type": "code",
},
{
"cell_type": "code",
- "execution_count":
74
,
+ "execution_count":
12
,
"metadata": {
"metadata": {
- "collapsed": false
+ "collapsed": false,
+ "jupyter": {
+ "outputs_hidden": false
+ }
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "
10 loops, best of 3: 44.4 ms per loop
\n"
+ "
53.5 ms ± 1.11 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
\n"
]
}
],
]
}
],
@@
-373,7
+403,7
@@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cell_type": "code",
"execution_count": null,
"metadata": {
- "
collapsed": true
+ "
tags": []
},
"outputs": [],
"source": []
},
"outputs": [],
"source": []
@@
-381,7
+411,7
@@
],
"metadata": {
"kernelspec": {
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3
(ipykernel)
",
"language": "python",
"name": "python3"
},
"language": "python",
"name": "python3"
},
@@
-395,9
+425,9
@@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.
4.3
"
+ "version": "3.
8.8
"
}
},
"nbformat": 4,
}
},
"nbformat": 4,
- "nbformat_minor":
0
+ "nbformat_minor":
4
}
}