From: Neil Smith Date: Wed, 15 Feb 2017 16:32:08 +0000 (+0000) Subject: Use none? rather than not empty? X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=b87dc3b407790077841f68fab3c072bbf180d71b;p=project-euler.git Use none? rather than not empty? --- diff --git a/euler32.ipynb b/euler32.ipynb index 4ce86d6..f3879f7 100644 --- a/euler32.ipynb +++ b/euler32.ipynb @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 88, "metadata": { "collapsed": false }, @@ -58,7 +58,7 @@ ":full_subbags" ] }, - "execution_count": 42, + "execution_count": 88, "metadata": {}, "output_type": "execute_result" } @@ -82,7 +82,7 @@ " \n", " def full_subbags(n)\n", " return enum_for(:full_subbags, n) unless block_given?\n", - " self.subbags(n).select {|bags| bags.all? {|b| !b.empty?}}.each do |bs|\n", + " self.subbags(n).select {|bags| bags.none? {|b| b.empty?}}.each do |bs|\n", " yield bs\n", " end\n", " end\n", @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 89, "metadata": { "collapsed": false }, @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 90, "metadata": { "collapsed": false }, @@ -121,7 +121,7 @@ "[[[1, 2, 3]]]" ] }, - "execution_count": 35, + "execution_count": 90, "metadata": {}, "output_type": "execute_result" } @@ -132,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 91, "metadata": { "collapsed": false }, @@ -157,7 +157,7 @@ "0..3" ] }, - "execution_count": 36, + "execution_count": 91, "metadata": {}, "output_type": "execute_result" } @@ -168,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 92, "metadata": { "collapsed": false }, @@ -179,7 +179,7 @@ "[[[], [1, 2, 3]], [[1], [2, 3]], [[2], [1, 3]], [[3], [1, 2]], [[1, 2], [3]], [[1, 3], [2]], [[2, 3], [1]], [[1, 2, 3], []]]" ] }, - "execution_count": 37, + "execution_count": 92, "metadata": {}, "output_type": "execute_result" } @@ -190,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 93, "metadata": { "collapsed": false }, @@ -201,7 +201,7 @@ "8" ] }, - "execution_count": 38, + "execution_count": 93, "metadata": {}, "output_type": "execute_result" } @@ -212,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 94, "metadata": { "collapsed": false }, @@ -223,7 +223,7 @@ "[[[], [], [1, 2, 3]], [[], [1], [2, 3]], [[], [2], [1, 3]], [[], [3], [1, 2]], [[], [1, 2], [3]], [[], [1, 3], [2]], [[], [2, 3], [1]], [[], [1, 2, 3], []], [[1], [], [2, 3]], [[1], [2], [3]], [[1], [3], [2]], [[1], [2, 3], []], [[2], [], [1, 3]], [[2], [1], [3]], [[2], [3], [1]], [[2], [1, 3], []], [[3], [], [1, 2]], [[3], [1], [2]], [[3], [2], [1]], [[3], [1, 2], []], [[1, 2], [], [3]], [[1, 2], [3], []], [[1, 3], [], [2]], [[1, 3], [2], []], [[2, 3], [], [1]], [[2, 3], [1], []], [[1, 2, 3], [], []]]" ] }, - "execution_count": 39, + "execution_count": 94, "metadata": {}, "output_type": "execute_result" } @@ -234,7 +234,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 95, "metadata": { "collapsed": false }, @@ -245,7 +245,7 @@ "27" ] }, - "execution_count": 40, + "execution_count": 95, "metadata": {}, "output_type": "execute_result" } @@ -256,7 +256,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 96, "metadata": { "collapsed": false }, @@ -281,7 +281,7 @@ "0..3" ] }, - "execution_count": 41, + "execution_count": 96, "metadata": {}, "output_type": "execute_result" } @@ -296,7 +296,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 97, "metadata": { "collapsed": false }, @@ -307,7 +307,7 @@ "[[[1], [2], [3, 4]], [[1], [3], [2, 4]], [[1], [4], [2, 3]], [[1], [2, 3], [4]], [[1], [2, 4], [3]], [[1], [3, 4], [2]], [[2], [1], [3, 4]], [[2], [3], [1, 4]], [[2], [4], [1, 3]], [[2], [1, 3], [4]], [[2], [1, 4], [3]], [[2], [3, 4], [1]], [[3], [1], [2, 4]], [[3], [2], [1, 4]], [[3], [4], [1, 2]], [[3], [1, 2], [4]], [[3], [1, 4], [2]], [[3], [2, 4], [1]], [[4], [1], [2, 3]], [[4], [2], [1, 3]], [[4], [3], [1, 2]], [[4], [1, 2], [3]], [[4], [1, 3], [2]], [[4], [2, 3], [1]], [[1, 2], [3], [4]], [[1, 2], [4], [3]], [[1, 3], [2], [4]], [[1, 3], [4], [2]], [[1, 4], [2], [3]], [[1, 4], [3], [2]], [[2, 3], [1], [4]], [[2, 3], [4], [1]], [[2, 4], [1], [3]], [[2, 4], [3], [1]], [[3, 4], [1], [2]], [[3, 4], [2], [1]]]" ] }, - "execution_count": 46, + "execution_count": 97, "metadata": {}, "output_type": "execute_result" } @@ -318,7 +318,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 98, "metadata": { "collapsed": false }, @@ -329,7 +329,7 @@ "18150" ] }, - "execution_count": 47, + "execution_count": 98, "metadata": {}, "output_type": "execute_result" }