From 8b029066d205440bab8af788762d6624bd31928c Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Sat, 14 Dec 2024 20:27:06 +0100 Subject: [PATCH] wip(solutions/gmacario): bruteforcing Day 11 Part 2 does not scale --- solutions/gmacario/day11/day11.ipynb | 145 ++++++++++++++++----------- 1 file changed, 85 insertions(+), 60 deletions(-) diff --git a/solutions/gmacario/day11/day11.ipynb b/solutions/gmacario/day11/day11.ipynb index 50e85cc..c4d94ed 100644 --- a/solutions/gmacario/day11/day11.ipynb +++ b/solutions/gmacario/day11/day11.ipynb @@ -62,21 +62,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "ic| time.ctime(): 'Sat Dec 14 20:22:02 2024'\n", - "ic| time.ctime(tm_begin): 'Sat Dec 14 20:22:02 2024'" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\n" + "ic| time.ctime(): 'Sat Dec 14 20:24:53 2024'\n", + "ic| time.ctime(tm_begin): 'Sat Dec 14 20:24:54 2024'\n" ] }, { "data": { "text/plain": [ - "'Sat Dec 14 20:22:02 2024'" + "'Sat Dec 14 20:24:54 2024'" ] }, "execution_count": 3, @@ -177,39 +170,40 @@ "name": "stderr", "output_type": "stream", "text": [ - "ic| len(stones): 11\n", - "ic| len(stones): 16\n", - "ic| len(stones): 23\n", - "ic| len(stones): 35\n" + "ic| n: 0, len(stones): 11\n", + "ic| n: 1, len(stones): 16\n", + "ic| n: 2, len(stones): " ] }, { "name": "stderr", "output_type": "stream", "text": [ - "ic| len(stones): 47\n", - "ic| len(stones): 78\n", - "ic| len(stones): 123\n", - "ic| len(stones): 173\n", - "ic| len(stones): 261\n", - "ic| len(stones): 394\n", - "ic| len(stones): 604\n", - "ic| len(stones): 877\n", - "ic| len(stones): 1330\n", - "ic| len(stones): 2134\n", - "ic| len(stones): 3129\n", - "ic| len(stones): 4593\n", - "ic| len(stones): 7243\n", - "ic| len(stones): 10966\n", - "ic| len(stones): 16469\n", - "ic| len(stones): 24973\n", - "ic| len(stones): 37948\n", - "ic| len(stones): 58245\n", - "ic| len(stones): 87294\n", - "ic| len(stones): 133331\n", - "ic| len(stones): 204022\n", + "23\n", + "ic| n: 3, len(stones): 35\n", + "ic| n: 4, len(stones): 47\n", + "ic| n: 5, len(stones): 78\n", + "ic| n: 6, len(stones): 123\n", + "ic| n: 7, len(stones): 173\n", + "ic| n: 8, len(stones): 261\n", + "ic| n: 9, len(stones): 394\n", + "ic| n: 10, len(stones): 604\n", + "ic| n: 11, len(stones): 877\n", + "ic| n: 12, len(stones): 1330\n", + "ic| n: 13, len(stones): 2134\n", + "ic| n: 14, len(stones): 3129\n", + "ic| n: 15, len(stones): 4593\n", + "ic| n: 16, len(stones): 7243\n", + "ic| n: 17, len(stones): 10966\n", + "ic| n: 18, len(stones): 16469\n", + "ic| n: 19, len(stones): 24973\n", + "ic| n: 20, len(stones): 37948\n", + "ic| n: 21, len(stones): 58245\n", + "ic| n: 22, len(stones): 87294\n", + "ic| n: 23, len(stones): 133331\n", + "ic| n: 24, len(stones): 204022\n", "ic| \"elapsed=\": 'elapsed='\n", - " tm_end - tm_begin: 0.5119881629943848\n", + " tm_end - tm_begin: 0.7288703918457031\n", " \"result=\": 'result='\n", " part1_result: 204022\n" ] @@ -231,7 +225,7 @@ " for n in range(25):\n", " stones = blink(stones)\n", " # _ = ic(stones)\n", - " ic(len(stones))\n", + " ic(n, len(stones))\n", " \n", " return len(stones)\n", "\n", @@ -253,37 +247,68 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "8555a6fb-c520-46f9-b6da-46cdc09b0ee7", + "execution_count": null, + "id": "51de10dc-4093-4fce-bd21-50ef40cdf1dd", "metadata": {}, "outputs": [ { - "ename": "AssertionError", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[8], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m \u001b[38;5;66;03m# TODO\u001b[39;00m\n", - "\u001b[0;31mAssertionError\u001b[0m: " + "name": "stderr", + "output_type": "stream", + "text": [ + "ic| n: 0, len(stones): 11\n", + "ic| n: 1, len(stones): 16\n", + "ic| n: 2, len(stones): 23\n", + "ic| n: 3, len(stones): 35\n", + "ic| n: 4, len(stones): 47\n", + "ic| n: 5, len(stones): 78\n", + "ic| n: 6, len(stones): 123\n", + "ic| n: 7, len(stones): 173\n", + "ic| n: 8, len(stones): 261\n", + "ic| n: 9, len(stones): 394\n", + "ic| n: 10, len(stones): 604\n", + "ic| n: 11, len(stones): 877\n", + "ic| n: 12, len(stones): 1330\n", + "ic| n: 13, len(stones): 2134\n", + "ic| n: 14, len(stones): 3129\n", + "ic| n: 15, len(stones): 4593\n", + "ic| n: 16, len(stones): 7243\n", + "ic| n: 17, len(stones): 10966\n", + "ic| n: 18, len(stones): 16469\n", + "ic| n: 19, len(stones): 24973\n", + "ic| n: 20, len(stones): 37948\n", + "ic| n: 21, len(stones): 58245\n", + "ic| n: 22, len(stones): 87294\n", + "ic| n: 23, len(stones): 133331\n", + "ic| n: 24, len(stones): 204022\n", + "ic| n: 25, len(stones): 305725\n", + "ic| n: 26, len(stones): 467210\n", + "ic| n: 27, len(stones): 710893\n", + "ic| n: 28, len(stones): 1077867\n", + "ic| n: 29, len(stones): 1639198\n", + "ic| n: 30, len(stones): 2478021\n", + "ic| n: 31, len(stones): 3785340\n", + "ic| n: 32, len(stones): 5744135\n", + "ic| n: 33, len(stones): 8690628\n", + "ic| n: 34, len(stones): 13262477\n", + "ic| n: 35, len(stones): 20093612\n", + "ic| n: 36, len(stones): 30523501\n", + "ic| n: 37, len(stones): 46418605\n", + "ic| n: 38, len(stones): 70383053\n", + "ic| n: 39, len(stones): 107140672\n" ] } ], - "source": [ - "assert False # TODO" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "51de10dc-4093-4fce-bd21-50ef40cdf1dd", - "metadata": {}, - "outputs": [], "source": [ "def solve_part2():\n", - " result = False\n", - " ...\n", - " return result\n", + " stones = input_stones\n", + " # _ = ic(stones)\n", + "\n", + " for n in range(75):\n", + " stones = blink(stones)\n", + " # _ = ic(stones)\n", + " ic(n, len(stones))\n", + " \n", + " return len(stones)\n", "\n", "# tm_begin = time.time()\n", "part2_result = solve_part2()\n",