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",
"* Can we create additional data structures?\n",
" * Yes\n",
"* Do you expect the function to return a new list?\n",
@@ -98,7 +97,7 @@
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
" \n",
"\n",
" def partition(self, data):\n",
" # TODO: Implement me\n",
" pass"
@@ -133,7 +132,7 @@
"\n",
"\n",
"class TestPartition(object):\n",
" \n",
"\n",
" def test_partition(self):\n",
" print('Test: Empty list')\n",
" linked_list = MyLinkedList(None)\n",
@@ -163,15 +162,17 @@
" linked_list.insert_to_front(3)\n",
" linked_list.insert_to_front(4)\n",
" partitioned_list = linked_list.partition(10)\n",
" assert_equal(partitioned_list.get_all_data(), \n",
" assert_equal(partitioned_list.get_all_data(),\n",
" [4, 3, 7, 8, 1, 10, 10, 12])\n",
" \n",
"\n",
" print('Success: test_partition')\n",
"\n",
"\n",
"def main():\n",
" test = TestPartition()\n",
" test.test_partition()\n",
" \n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can we create additional data structures?\n",
" * Yes\n",
"* Do you expect the function to return a new list?\n",
@@ -104,14 +103,14 @@
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
" \n",
"\n",
" def partition(self, data):\n",
" if self.head is None:\n",
" return\n",
" left = MyLinkedList(None)\n",
" right = MyLinkedList(None)\n",
" curr = self.head\n",
" \n",
"\n",
" # Build the left and right lists\n",
" while curr is not None:\n",
" if curr.data < data:\n",
@@ -158,7 +157,7 @@
"\n",
"\n",
"class TestPartition(object):\n",
" \n",
"\n",
" def test_partition(self):\n",
" print('Test: Empty list')\n",
" linked_list = MyLinkedList(None)\n",
@@ -188,15 +187,17 @@
" linked_list.insert_to_front(3)\n",
" linked_list.insert_to_front(4)\n",
" partitioned_list = linked_list.partition(10)\n",
" assert_equal(partitioned_list.get_all_data(), \n",
" assert_equal(partitioned_list.get_all_data(),\n",
" [4, 3, 7, 8, 1, 10, 10, 12])\n",
" \n",
"\n",
" print('Success: test_partition')\n",
"\n",
"\n",
"def main():\n",
" test = TestPartition()\n",
" test.test_partition()\n",
" \n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@@ -2,7 +2,7 @@ from nose.tools import assert_equal
class TestPartition(object):
def test_partition(self):
print('Test: Empty list')
linked_list = MyLinkedList(None)
@@ -32,14 +32,16 @@ class TestPartition(object):
linked_list.insert_to_front(3)
linked_list.insert_to_front(4)
partitioned_list = linked_list.partition(10)
assert_equal(partitioned_list.get_all_data(),
assert_equal(partitioned_list.get_all_data(),
[4, 3, 7, 8, 1, 10, 10, 12])
print('Success: test_partition')
def main():
test = TestPartition()
test.test_partition()
if __name__ == '__main__':
main()