mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-11 11:58:02 +00:00
@@ -102,9 +102,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Grid(object):\n",
|
||||
@@ -131,21 +129,19 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_grid_path.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestGridPath(object):\n",
|
||||
"class TestGridPath(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_grid_path(self):\n",
|
||||
" grid = Grid()\n",
|
||||
" assert_equal(grid.find_path(None), None)\n",
|
||||
" assert_equal(grid.find_path([[]]), None)\n",
|
||||
" self.assertEqual(grid.find_path(None), None)\n",
|
||||
" self.assertEqual(grid.find_path([[]]), None)\n",
|
||||
" max_rows = 8\n",
|
||||
" max_cols = 4\n",
|
||||
" matrix = [[1] * max_cols for _ in range(max_rows)]\n",
|
||||
@@ -162,10 +158,10 @@
|
||||
" (2, 1), (3, 1), (4, 1),\n",
|
||||
" (5, 1), (5, 2), (6, 2), \n",
|
||||
" (7, 2), (7, 3)]\n",
|
||||
" assert_equal(result, expected)\n",
|
||||
" self.assertEqual(result, expected)\n",
|
||||
" matrix[7][2] = 0\n",
|
||||
" result = grid.find_path(matrix)\n",
|
||||
" assert_equal(result, None)\n",
|
||||
" self.assertEqual(result, None)\n",
|
||||
" print('Success: test_grid_path')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -204,9 +200,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
|
||||
}
|
||||
|
||||
@@ -135,9 +135,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Grid(object):\n",
|
||||
@@ -177,9 +175,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -191,15 +187,15 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_grid_path.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestGridPath(object):\n",
|
||||
"class TestGridPath(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_grid_path(self):\n",
|
||||
" grid = Grid()\n",
|
||||
" assert_equal(grid.find_path(None), None)\n",
|
||||
" assert_equal(grid.find_path([[]]), None)\n",
|
||||
" self.assertEqual(grid.find_path(None), None)\n",
|
||||
" self.assertEqual(grid.find_path([[]]), None)\n",
|
||||
" max_rows = 8\n",
|
||||
" max_cols = 4\n",
|
||||
" matrix = [[1] * max_cols for _ in range(max_rows)]\n",
|
||||
@@ -216,10 +212,10 @@
|
||||
" (2, 1), (3, 1), (4, 1),\n",
|
||||
" (5, 1), (5, 2), (6, 2), \n",
|
||||
" (7, 2), (7, 3)]\n",
|
||||
" assert_equal(result, expected)\n",
|
||||
" self.assertEqual(result, expected)\n",
|
||||
" matrix[7][2] = 0\n",
|
||||
" result = grid.find_path(matrix)\n",
|
||||
" assert_equal(result, None)\n",
|
||||
" self.assertEqual(result, None)\n",
|
||||
" print('Success: test_grid_path')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -235,9 +231,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -268,9 +262,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,12 +1,12 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
class TestGridPath(object):
|
||||
class TestGridPath(unittest.TestCase):
|
||||
|
||||
def test_grid_path(self):
|
||||
grid = Grid()
|
||||
assert_equal(grid.find_path(None), None)
|
||||
assert_equal(grid.find_path([[]]), None)
|
||||
self.assertEqual(grid.find_path(None), None)
|
||||
self.assertEqual(grid.find_path([[]]), None)
|
||||
max_rows = 8
|
||||
max_cols = 4
|
||||
matrix = [[1] * max_cols for _ in range(max_rows)]
|
||||
@@ -23,10 +23,10 @@ class TestGridPath(object):
|
||||
(2, 1), (3, 1), (4, 1),
|
||||
(5, 1), (5, 2), (6, 2),
|
||||
(7, 2), (7, 3)]
|
||||
assert_equal(result, expected)
|
||||
self.assertEqual(result, expected)
|
||||
matrix[7][2] = 0
|
||||
result = grid.find_path(matrix)
|
||||
assert_equal(result, None)
|
||||
self.assertEqual(result, None)
|
||||
print('Success: test_grid_path')
|
||||
|
||||
|
||||
@@ -36,4 +36,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user