mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 17:08:02 +00:00
@@ -91,8 +91,8 @@
|
||||
"graph.add_edge('h', 'g', weight=2)\n",
|
||||
"shortest_path = ShortestPath(graph)\n",
|
||||
"result = shortest_path.find_shortest_path('a', 'i')\n",
|
||||
"assert_equal(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
"assert_equal(shortest_path.path_weight['i'], 8)\n",
|
||||
"self.assertEqual(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
"self.assertEqual(shortest_path.path_weight['i'], 8)\n",
|
||||
"</pre>"
|
||||
]
|
||||
},
|
||||
@@ -174,10 +174,10 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_shortest_path.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestShortestPath(object):\n",
|
||||
"class TestShortestPath(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_shortest_path(self):\n",
|
||||
" graph = Graph()\n",
|
||||
@@ -202,8 +202,8 @@
|
||||
" graph.add_edge('h', 'g', weight=2)\n",
|
||||
" shortest_path = ShortestPath(graph)\n",
|
||||
" result = shortest_path.find_shortest_path('a', 'i')\n",
|
||||
" assert_equal(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
" assert_equal(shortest_path.path_weight['i'], 8)\n",
|
||||
" self.assertEqual(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
" self.assertEqual(shortest_path.path_weight['i'], 8)\n",
|
||||
"\n",
|
||||
" print('Success: test_shortest_path')\n",
|
||||
"\n",
|
||||
@@ -243,7 +243,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.4"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -90,8 +90,8 @@
|
||||
"graph.add_edge('h', 'g', weight=2)\n",
|
||||
"shortest_path = ShortestPath(graph)\n",
|
||||
"result = shortest_path.find_shortest_path('a', 'i')\n",
|
||||
"assert_equal(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
"assert_equal(shortest_path.path_weight['i'], 8)\n",
|
||||
"self.assertEqual(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
"self.assertEqual(shortest_path.path_weight['i'], 8)\n",
|
||||
"</pre>"
|
||||
]
|
||||
},
|
||||
@@ -154,9 +154,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../../arrays_strings/priority_queue/priority_queue.py"
|
||||
@@ -165,9 +163,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../graph/graph.py"
|
||||
@@ -176,9 +172,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sys\n",
|
||||
@@ -254,9 +248,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -268,10 +260,10 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_shortest_path.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestShortestPath(object):\n",
|
||||
"class TestShortestPath(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_shortest_path(self):\n",
|
||||
" graph = Graph()\n",
|
||||
@@ -296,8 +288,8 @@
|
||||
" graph.add_edge('h', 'g', weight=2)\n",
|
||||
" shortest_path = ShortestPath(graph)\n",
|
||||
" result = shortest_path.find_shortest_path('a', 'i')\n",
|
||||
" assert_equal(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
" assert_equal(shortest_path.path_weight['i'], 8)\n",
|
||||
" self.assertEqual(result, ['a', 'c', 'd', 'g', 'i'])\n",
|
||||
" self.assertEqual(shortest_path.path_weight['i'], 8)\n",
|
||||
"\n",
|
||||
" print('Success: test_shortest_path')\n",
|
||||
"\n",
|
||||
@@ -314,9 +306,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -347,9 +337,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
class TestShortestPath(object):
|
||||
class TestShortestPath(unittest.TestCase):
|
||||
|
||||
def test_shortest_path(self):
|
||||
graph = Graph()
|
||||
@@ -26,8 +26,8 @@ class TestShortestPath(object):
|
||||
graph.add_edge('h', 'g', weight=2)
|
||||
shortest_path = ShortestPath(graph)
|
||||
result = shortest_path.find_shortest_path('a', 'i')
|
||||
assert_equal(result, ['a', 'c', 'd', 'g', 'i'])
|
||||
assert_equal(shortest_path.path_weight['i'], 8)
|
||||
self.assertEqual(result, ['a', 'c', 'd', 'g', 'i'])
|
||||
self.assertEqual(shortest_path.path_weight['i'], 8)
|
||||
|
||||
print('Success: test_shortest_path')
|
||||
|
||||
@@ -38,4 +38,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user