mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 02:48:02 +00:00
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user