From 9ef548dfbbbf42d33513853275210f3b5bbe62e1 Mon Sep 17 00:00:00 2001 From: filifa Date: Mon, 14 Apr 2025 21:05:20 -0400 Subject: [PATCH] add problem 29 --- problem0029.ipynb | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 problem0029.ipynb diff --git a/problem0029.ipynb b/problem0029.ipynb new file mode 100644 index 0000000..6a1173a --- /dev/null +++ b/problem0029.ipynb @@ -0,0 +1,56 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3bbfb66e", + "metadata": {}, + "source": [ + "# [Distinct Powers](https://projecteuler.net/problem=29)\n", + "\n", + "Python offers a [built-in set type](https://docs.python.org/3/library/stdtypes.html) that will only keep track of distinct items for us. We also don't need to worry about overflows, since integers are unlimited precision." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "9fa32dcf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "9183" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len({a ** b for a in range(2, 101) for b in range(2, 101)})" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 9.5", + "language": "sage", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}