mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 01:18:02 +00:00
@@ -85,9 +85,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MinBst(object):\n",
|
||||
@@ -113,13 +111,11 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_bst_min.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def height(node):\n",
|
||||
@@ -129,18 +125,18 @@
|
||||
" height(node.right))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestBstMin(object):\n",
|
||||
"class TestBstMin(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_bst_min(self):\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 3)\n",
|
||||
" self.assertEqual(height(root), 3)\n",
|
||||
"\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6, 7]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 4)\n",
|
||||
" self.assertEqual(height(root), 4)\n",
|
||||
"\n",
|
||||
" print('Success: test_bst_min')\n",
|
||||
"\n",
|
||||
@@ -180,9 +176,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -83,9 +83,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../bst/bst.py"
|
||||
@@ -93,10 +91,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from __future__ import division\n",
|
||||
@@ -129,9 +125,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -143,7 +137,7 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_bst_min.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def height(node):\n",
|
||||
@@ -153,18 +147,18 @@
|
||||
" height(node.right))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestBstMin(object):\n",
|
||||
"class TestBstMin(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_bst_min(self):\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 3)\n",
|
||||
" self.assertEqual(height(root), 3)\n",
|
||||
"\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6, 7]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 4)\n",
|
||||
" self.assertEqual(height(root), 4)\n",
|
||||
"\n",
|
||||
" print('Success: test_bst_min')\n",
|
||||
"\n",
|
||||
@@ -181,9 +175,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -214,9 +206,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
def height(node):
|
||||
@@ -8,18 +8,18 @@ def height(node):
|
||||
height(node.right))
|
||||
|
||||
|
||||
class TestBstMin(object):
|
||||
class TestBstMin(unittest.TestCase):
|
||||
|
||||
def test_bst_min(self):
|
||||
min_bst = MinBst()
|
||||
array = [0, 1, 2, 3, 4, 5, 6]
|
||||
root = min_bst.create_min_bst(array)
|
||||
assert_equal(height(root), 3)
|
||||
self.assertEqual(height(root), 3)
|
||||
|
||||
min_bst = MinBst()
|
||||
array = [0, 1, 2, 3, 4, 5, 6, 7]
|
||||
root = min_bst.create_min_bst(array)
|
||||
assert_equal(height(root), 4)
|
||||
self.assertEqual(height(root), 4)
|
||||
|
||||
print('Success: test_bst_min')
|
||||
|
||||
@@ -30,4 +30,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user