diff --git a/day 7/day7_bob.ipynb b/day 7/day_7_bob.ipynb similarity index 91% rename from day 7/day7_bob.ipynb rename to day 7/day_7_bob.ipynb index e0ef94c67f3fddedb3c63c16be30f682ddd33089..cdfb780f70b7f161c982f8bc21934ba0aa217ff1 100644 --- a/day 7/day7_bob.ipynb +++ b/day 7/day_7_bob.ipynb @@ -1,18 +1,4 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "provenance": [] - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "code", @@ -35,34 +21,48 @@ }, { "cell_type": "code", - "source": [ - "# part 2 (in part 1 skip last case in return statement)\n", - "def solve(x, s, target):\n", - " if not x or s > target: return s == target\n", - " return solve(x[1:], s + x[0], target) or solve(x[1:], s * x[0], target) or solve(x[1:], int(str(s) + str(x[0])), target)\n", - "\n", - "sum(target for target, elements in zip(*readdata('input07.txt')) if solve(elements[1:], elements[0], target))" - ], + "execution_count": 16, "metadata": { - "id": "n41e8HbQgZ7R", "colab": { "base_uri": "https://localhost:8080/" }, + "id": "n41e8HbQgZ7R", "outputId": "aca2ad7d-3dcb-400f-99a3-8719bfa8917e" }, - "execution_count": 16, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "162987117690649" ] }, + "execution_count": 16, "metadata": {}, - "execution_count": 16 + "output_type": "execute_result" } + ], + "source": [ + "# part 2 (in part 1 skip last case in return statement)\n", + "def solve(x, s, target):\n", + " if not x or s > target: return s == target\n", + " return solve(x[1:], s + x[0], target) or solve(x[1:], s * x[0], target) or solve(x[1:], int(str(s) + str(x[0])), target)\n", + "\n", + "sum(target for target, elements in zip(*readdata('input07.txt')) if solve(elements[1:], elements[0], target))" ] } - ] -} \ No newline at end of file + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}