Fix #13, PEP8-ify notebooks.

This commit is contained in:
Donne Martin
2015-07-11 15:34:52 -04:00
parent 374d67ff30
commit 04083b2011
25 changed files with 210 additions and 173 deletions

View File

@@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* What if the final node is being deleted, for example a single node list? Do we make it a dummy with value None?\n",
" * Yes\n",
"* Can we assume we already have a linked list class that can be used for this problem?\n",
@@ -90,7 +89,7 @@
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
" \n",
"\n",
" def delete_node(self, node):\n",
" # TODO: Implement me\n",
" pass"
@@ -125,7 +124,7 @@
"\n",
"\n",
"class TestDeleteNode(object):\n",
" \n",
"\n",
" def test_delete_node(self):\n",
" print('Test: Empty list, null node to delete')\n",
" linked_list = MyLinkedList(None)\n",
@@ -139,20 +138,22 @@
" assert_equal(linked_list.get_all_data(), [None])\n",
"\n",
" print('Test: Multiple nodes')\n",
" linked_list = MyLinkedList(None) \n",
" linked_list = MyLinkedList(None)\n",
" node0 = linked_list.insert_to_front(1)\n",
" node1 = linked_list.insert_to_front(3)\n",
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node2)\n",
" assert_equal(linked_list.get_all_data(), [1, 3, 1])\n",
" \n",
"\n",
" print('Success: test_delete_node')\n",
"\n",
"\n",
"def main():\n",
" test = TestDeleteNode()\n",
" test.test_delete_node()\n",
" \n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* What if the final node is being deleted, for example a single node list? Do we make it a dummy with value None?\n",
" * Yes\n",
"* Can we assume we already have a linked list class that can be used for this problem?\n",
@@ -95,7 +94,7 @@
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
" \n",
"\n",
" def delete_node(self, node):\n",
" if self.head is None:\n",
" return\n",
@@ -138,7 +137,7 @@
"\n",
"\n",
"class TestDeleteNode(object):\n",
" \n",
"\n",
" def test_delete_node(self):\n",
" print('Test: Empty list, null node to delete')\n",
" linked_list = MyLinkedList(None)\n",
@@ -152,20 +151,22 @@
" assert_equal(linked_list.get_all_data(), [None])\n",
"\n",
" print('Test: Multiple nodes')\n",
" linked_list = MyLinkedList(None) \n",
" linked_list = MyLinkedList(None)\n",
" node0 = linked_list.insert_to_front(1)\n",
" node1 = linked_list.insert_to_front(3)\n",
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node2)\n",
" assert_equal(linked_list.get_all_data(), [1, 3, 1])\n",
" \n",
"\n",
" print('Success: test_delete_node')\n",
"\n",
"\n",
"def main():\n",
" test = TestDeleteNode()\n",
" test.test_delete_node()\n",
" \n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@@ -2,7 +2,7 @@ from nose.tools import assert_equal
class TestDeleteNode(object):
def test_delete_node(self):
print('Test: Empty list, null node to delete')
linked_list = MyLinkedList(None)
@@ -16,19 +16,21 @@ class TestDeleteNode(object):
assert_equal(linked_list.get_all_data(), [None])
print('Test: Multiple nodes')
linked_list = MyLinkedList(None)
linked_list = MyLinkedList(None)
node0 = linked_list.insert_to_front(1)
node1 = linked_list.insert_to_front(3)
node2 = linked_list.insert_to_front(4)
node3 = linked_list.insert_to_front(1)
linked_list.delete_node(node2)
assert_equal(linked_list.get_all_data(), [1, 3, 1])
print('Success: test_delete_node')
def main():
test = TestDeleteNode()
test.test_delete_node()
if __name__ == '__main__':
main()