From c0270852b2fec6413e8a5841d42e944fc12852dc Mon Sep 17 00:00:00 2001 From: BoB <bo.bernhardsson@control.lth.se> Date: Sat, 7 Dec 2024 11:57:00 +0000 Subject: [PATCH] day7_oneliner --- day 7/day_7_oneliner_bob.ipynb | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 day 7/day_7_oneliner_bob.ipynb diff --git a/day 7/day_7_oneliner_bob.ipynb b/day 7/day_7_oneliner_bob.ipynb new file mode 100644 index 0000000..66c95c6 --- /dev/null +++ b/day 7/day_7_oneliner_bob.ipynb @@ -0,0 +1,44 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "source": [ + "sum(t for t, e in zip(*zip(*[(int(t.strip()), list(map(int, e.strip().split()))) for t, e in (line.split(\":\") for line in open('input07.txt'))])) if (f := lambda x, s, t: (s == t) if (not x or s > t) else f(x[1:], s + x[0], t) or f(x[1:], s * x[0], t) or f(x[1:], int(str(s) + str(x[0])), t))(e[1:], e[0], t))" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_HtCCdtN9T9u", + "outputId": "09992b8c-dcf8-4de1-c21d-e0af99ca8096" + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "162987117690649" + ] + }, + "metadata": {}, + "execution_count": 2 + } + ] + } + ] +} \ No newline at end of file -- GitLab