From: Neil Smith Date: Wed, 22 Jun 2022 10:34:53 +0000 (+0100) Subject: Fixed typo X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-15.git;a=commitdiff_plain Fixed typo --- diff --git a/advent19.ipynb b/advent19.ipynb index f096690..2288bcc 100644 --- a/advent19.ipynb +++ b/advent19.ipynb @@ -2,9 +2,9 @@ "cells": [ { "cell_type": "code", - "execution_count": 10, + "execution_count": 1, "metadata": { - "collapsed": true + "tags": [] }, "outputs": [], "source": [ @@ -15,14 +15,17 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#Part 1" + "# Part 1" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -75,7 +78,7 @@ " 'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl']" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -87,9 +90,12 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -140,7 +146,7 @@ " ['e', 'OMg']]" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -152,9 +158,12 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 4, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -163,7 +172,7 @@ "'CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl'" ] }, - "execution_count": 8, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -177,7 +186,10 @@ "cell_type": "code", "execution_count": 5, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -198,15 +210,18 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 7, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "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])" @@ -214,9 +229,12 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -225,7 +243,7 @@ "518" ] }, - "execution_count": 19, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -238,14 +256,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#Part 2" + "# Part 2" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 9, "metadata": { - "collapsed": true + "tags": [] }, "outputs": [], "source": [ @@ -256,18 +274,21 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 14, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [], "source": [ "#This is infeasible\n", "\n", - "#agenda = [(base, 0)]\n", - "#closed_set = set()\n", + "# agenda = [(base, 0)]\n", + "# closed_set = set()\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", @@ -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", - "#agenda[0]" + "# agenda[0]" ] }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 15, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "outputs": [ { @@ -292,7 +316,7 @@ "('e', 200)" ] }, - "execution_count": 75, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -312,16 +336,19 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 11, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "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", - "execution_count": 74, + "execution_count": 12, "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, "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": { - "collapsed": true + "tags": [] }, "outputs": [], "source": [] @@ -381,7 +411,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -395,9 +425,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.8.8" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 }