Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix inconsistencies between graph challenge and solution #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions graphs_trees/graph/graph_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin) and [Kevin Chan](https://github.com/kevinxchan). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
Expand Down Expand Up @@ -145,11 +145,11 @@
" # TODO: Implement me\n",
" pass\n",
"\n",
" def add_edge(self, source, dest, weight=0):\n",
" def add_edge(self, source_key, dest_key, weight=0):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
" def add_undirected_edge(self, source, dest, weight=0):\n",
" def add_undirected_edge(self, source_key, dest_key, weight=0):\n",
" # TODO: Implement me\n",
" pass"
]
Expand Down
50 changes: 13 additions & 37 deletions graphs_trees/graph/graph_solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin) and [Kevin Chan](https://github.com/kevinxchan). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
Expand Down Expand Up @@ -153,19 +153,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting graph.py\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile graph.py\n",
"from enum import Enum # Python 2 users: Run pip install enum34\n",
Expand Down Expand Up @@ -231,19 +221,17 @@
" self.add_node(dest_key)\n",
" self.nodes[source_key].add_neighbor(self.nodes[dest_key], weight)\n",
"\n",
" def add_undirected_edge(self, src_key, dst_key, weight=0):\n",
" def add_undirected_edge(self, source_key, dest_key, weight=0):\n",
" if src_key is None or dst_key is None:\n",
" raise TypeError('key cannot be None')\n",
" self.add_edge(src_key, dst_key, weight)\n",
" self.add_edge(dst_key, src_key, weight)"
" self.add_edge(source_key, dest_key, weight)\n",
" self.add_edge(dest_key, source_key, weight)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run graph.py"
Expand All @@ -258,19 +246,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting test_graph.py\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile test_graph.py\n",
"from nose.tools import assert_equal\n",
Expand Down Expand Up @@ -351,9 +329,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -389,5 +365,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}