From 0ee19fa69fb29dcc18aeb8654f8c751a5e58975d Mon Sep 17 00:00:00 2001 From: Felix Martin Date: Mon, 24 Dec 2018 18:41:37 -0500 Subject: [PATCH] Verified 53 til 57. --- ipython/EulerProblem053.ipynb | 13 +++++++-- ipython/EulerProblem054.ipynb | 27 ++++++++++++----- ipython/EulerProblem055.ipynb | 24 ++++++++++------ ipython/EulerProblem056.ipynb | 14 +++++---- ipython/EulerProblem057.ipynb | 38 +++++++++++++----------- ipython/html/EulerProblem055.html | 7 +++-- ipython/html/EulerProblem056.html | 5 ++-- ipython/html/EulerProblem057.html | 19 ++++++------ ipython/html/index.html | 48 ++++++++++++++++++++++++------- 9 files changed, 132 insertions(+), 63 deletions(-) diff --git a/ipython/EulerProblem053.ipynb b/ipython/EulerProblem053.ipynb index b370f57..67ad64d 100644 --- a/ipython/EulerProblem053.ipynb +++ b/ipython/EulerProblem053.ipynb @@ -51,7 +51,9 @@ { "cell_type": "code", "execution_count": 7, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "count = 0\n", @@ -93,7 +95,7 @@ } ], "metadata": { - "completion_date": "", + "completion_date": "Mon, 24 Dec 2018, 23:29", "kernelspec": { "display_name": "Python 3", "language": "python3.6", @@ -111,7 +113,12 @@ "pygments_lexer": "ipython3", "version": "3.6.5" }, - "tags": [] + "tags": [ + "combinatoric", + "selection", + "factorial", + "airplane" + ] }, "nbformat": 4, "nbformat_minor": 2 diff --git a/ipython/EulerProblem054.ipynb b/ipython/EulerProblem054.ipynb index 012bf64..38406df 100644 --- a/ipython/EulerProblem054.ipynb +++ b/ipython/EulerProblem054.ipynb @@ -60,7 +60,9 @@ { "cell_type": "code", "execution_count": 21, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def suit_to_value(suit):\n", @@ -110,7 +112,9 @@ { "cell_type": "code", "execution_count": 37, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def get_numbered_groups(ns):\n", @@ -142,7 +146,9 @@ { "cell_type": "code", "execution_count": 45, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def rank(hand):\n", @@ -187,7 +193,9 @@ { "cell_type": "code", "execution_count": 55, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "assert(rank([\"5H\", \"5C\", \"6S\", \"7S\", \"KD\"]) == [1, [(2, 5), (1, 13), (1, 7), (1, 6)]]) # Pair of Fives\n", @@ -205,7 +213,9 @@ { "cell_type": "code", "execution_count": 67, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def read_hands():\n", @@ -262,7 +272,7 @@ } ], "metadata": { - "completion_date": "", + "completion_date": "Mon, 24 Dec 2018, 23:30", "kernelspec": { "display_name": "Python 3", "language": "python3.6", @@ -280,7 +290,10 @@ "pygments_lexer": "ipython3", "version": "3.6.5" }, - "tags": [] + "tags": [ + "poker", + "airplane" + ] }, "nbformat": 4, "nbformat_minor": 2 diff --git a/ipython/EulerProblem055.ipynb b/ipython/EulerProblem055.ipynb index c962357..e1b28ce 100644 --- a/ipython/EulerProblem055.ipynb +++ b/ipython/EulerProblem055.ipynb @@ -38,8 +38,10 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, + "execution_count": 1, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def get_digits(n):\n", @@ -80,8 +82,10 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, + "execution_count": 2, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def is_not_lychrel(n, iterations=50):\n", @@ -98,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -112,7 +116,8 @@ "source": [ "lychrels = [n for n in range(1, 10000) if is_not_lychrel(n) == 0]\n", "s = len(lychrels)\n", - "print(s)" + "print(s)\n", + "assert(s == 249)" ] }, { @@ -126,7 +131,7 @@ } ], "metadata": { - "completion_date": "", + "completion_date": "Mon, 24 Dec 2018, 23:32", "kernelspec": { "display_name": "Python 3", "language": "python3.6", @@ -144,7 +149,10 @@ "pygments_lexer": "ipython3", "version": "3.6.5" }, - "tags": [] + "tags": [ + "lychrel", + "airplane" + ] }, "nbformat": 4, "nbformat_minor": 2 diff --git a/ipython/EulerProblem056.ipynb b/ipython/EulerProblem056.ipynb index d372239..487b5e8 100644 --- a/ipython/EulerProblem056.ipynb +++ b/ipython/EulerProblem056.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": { "collapsed": true }, @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -52,7 +52,8 @@ ], "source": [ "s = max([get_digit_sum(a**b) for a in range(1, 100) for b in range(1, 100)])\n", - "print(s)" + "print(s)\n", + "assert(s == 972)" ] }, { @@ -66,7 +67,7 @@ } ], "metadata": { - "completion_date": "", + "completion_date": "Mon, 24 Dec 2018, 23:33", "kernelspec": { "display_name": "Python 3", "language": "python3.6", @@ -84,7 +85,10 @@ "pygments_lexer": "ipython3", "version": "3.6.5" }, - "tags": [] + "tags": [ + "power", + "brute force" + ] }, "nbformat": 4, "nbformat_minor": 2 diff --git a/ipython/EulerProblem057.ipynb b/ipython/EulerProblem057.ipynb index 5415e27..049c7ce 100644 --- a/ipython/EulerProblem057.ipynb +++ b/ipython/EulerProblem057.ipynb @@ -36,23 +36,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, + "execution_count": 1, + "metadata": {}, "outputs": [], "source": [ "def get_digit_count(n):\n", - " c = 1\n", + " c = 0\n", " while n:\n", - " n += 1\n", + " c += 1\n", " n //= 10\n", - " return d" + " return c\n", + "\n", + "assert(get_digit_count(1337) == 4)" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 2, "metadata": { "collapsed": true }, @@ -78,10 +78,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": true - }, + "execution_count": 3, + "metadata": {}, "outputs": [], "source": [ "def next_expension(n, d):\n", @@ -92,14 +90,14 @@ "\n", "n, d = (3, 2)\n", "for i in range(1000):\n", - " if get_digit_count(n)> get_digit_count(d):\n", + " if get_digit_count(n) > get_digit_count(d):\n", " c += 1\n", " n, d = next_expension(n, d)" ] }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -112,7 +110,8 @@ ], "source": [ "s = c\n", - "print(s)" + "print(s)\n", + "assert(s == 153)" ] }, { @@ -126,7 +125,7 @@ } ], "metadata": { - "completion_date": "", + "completion_date": "Mon, 24 Dec 2018, 23:35", "kernelspec": { "display_name": "Python 3", "language": "python3.6", @@ -144,7 +143,12 @@ "pygments_lexer": "ipython3", "version": "3.6.5" }, - "tags": [] + "tags": [ + "square root", + "gcd", + "airplane", + "fractions" + ] }, "nbformat": 4, "nbformat_minor": 2 diff --git a/ipython/html/EulerProblem055.html b/ipython/html/EulerProblem055.html index 5b5fd93..4edb9df 100644 --- a/ipython/html/EulerProblem055.html +++ b/ipython/html/EulerProblem055.html @@ -11794,7 +11794,7 @@ div#notebook {
-
In [10]:
+
In [1]:
def get_digits(n):
@@ -11838,7 +11838,7 @@ div#notebook {
 
-
In [24]:
+
In [2]:
def is_not_lychrel(n, iterations=50):
@@ -11858,12 +11858,13 @@ div#notebook {
 
-
In [27]:
+
In [3]:
lychrels = [n for n in range(1, 10000) if is_not_lychrel(n) == 0]
 s = len(lychrels)
 print(s)
+assert(s == 249)
 
diff --git a/ipython/html/EulerProblem056.html b/ipython/html/EulerProblem056.html index 0fa3cdb..0b06d29 100644 --- a/ipython/html/EulerProblem056.html +++ b/ipython/html/EulerProblem056.html @@ -11785,7 +11785,7 @@ div#notebook {
-
In [3]:
+
In [1]:
def get_digit_sum(n):
@@ -11804,11 +11804,12 @@ div#notebook {
 
-
In [8]:
+
In [2]:
s = max([get_digit_sum(a**b) for a in range(1, 100) for b in range(1, 100)])
 print(s)
+assert(s == 972)
 
diff --git a/ipython/html/EulerProblem057.html b/ipython/html/EulerProblem057.html index 6eaef0a..5bed655 100644 --- a/ipython/html/EulerProblem057.html +++ b/ipython/html/EulerProblem057.html @@ -11793,15 +11793,17 @@ div#notebook {
-
In [ ]:
+
In [1]:
def get_digit_count(n):
-    c = 1
+    c = 0
     while n:
-        n += 1
+        c += 1
         n //= 10
-    return d
+    return c
+
+assert(get_digit_count(1337) == 4)
 
@@ -11809,7 +11811,7 @@ div#notebook {
-
In [44]:
+
In [2]:
def gcd(a, b):
@@ -11835,7 +11837,7 @@ div#notebook {
 
-
In [54]:
+
In [3]:
def next_expension(n, d):
@@ -11846,7 +11848,7 @@ div#notebook {
 
 n, d = (3, 2)
 for i in range(1000):
-    if get_digit_count(n)> get_digit_count(d):
+    if get_digit_count(n) > get_digit_count(d):
         c += 1
     n, d = next_expension(n, d)
 
@@ -11856,11 +11858,12 @@ div#notebook {
-
In [55]:
+
In [4]:
s = c
 print(s)
+assert(s == 153)
 
diff --git a/ipython/html/index.html b/ipython/html/index.html index 501b585..984491f 100644 --- a/ipython/html/index.html +++ b/ipython/html/index.html @@ -839,52 +839,80 @@ - + Problem 053 - + Mon, 24 Dec 2018, 23:29 + combinatoric + + selection + + factorial + + airplane + - + Problem 054 - + Mon, 24 Dec 2018, 23:30 + poker + + airplane + - + Problem 055 - + Mon, 24 Dec 2018, 23:32 + lychrel + + airplane + - + Problem 056 - + Mon, 24 Dec 2018, 23:33 + power + + brute force + - + Problem 057 - + Mon, 24 Dec 2018, 23:35 + square root + + gcd + + airplane + + fractions +