From 108be2b5906c3bfba8bef94d4dcf16576a8f7187 Mon Sep 17 00:00:00 2001 From: filifa Date: Sun, 20 Jul 2025 15:09:47 -0400 Subject: [PATCH] display the numbers of interest --- notebooks/problem0038.ipynb | 79 +++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/notebooks/problem0038.ipynb b/notebooks/problem0038.ipynb index 79757ab..5d5937f 100644 --- a/notebooks/problem0038.ipynb +++ b/notebooks/problem0038.ipynb @@ -15,18 +15,7 @@ "execution_count": 1, "id": "ffea7112", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "932718654" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from itertools import count\n", "\n", @@ -34,7 +23,7 @@ " return ''.join(sorted(s)) == \"123456789\"\n", "\n", "\n", - "pandigitals = set()\n", + "pandigitals = dict()\n", "for k in range(1, 10000):\n", " s = \"\"\n", " for n in count(1):\n", @@ -43,10 +32,66 @@ " break\n", " \n", " if is_pandigital(s):\n", - " pandigitals.add(int(s))\n", - "\n", - " \n", - "max(pandigitals)" + " pandigitals[k] = int(s)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6fe58cf9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{1: 123456789,\n", + " 9: 918273645,\n", + " 192: 192384576,\n", + " 219: 219438657,\n", + " 273: 273546819,\n", + " 327: 327654981,\n", + " 6729: 672913458,\n", + " 6792: 679213584,\n", + " 6927: 692713854,\n", + " 7269: 726914538,\n", + " 7293: 729314586,\n", + " 7329: 732914658,\n", + " 7692: 769215384,\n", + " 7923: 792315846,\n", + " 7932: 793215864,\n", + " 9267: 926718534,\n", + " 9273: 927318546,\n", + " 9327: 932718654}" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pandigitals" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "faf514b8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "932718654" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "max(pandigitals.values())" ] } ],