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

@@ -103,22 +103,22 @@
"\n",
"\n",
"class MyLinkedList(LinkedList):\n",
" \n",
"\n",
" def is_palindrome(self):\n",
" if self.head is None or self.head.next is None:\n",
" return False\n",
" curr = self.head\n",
" reversed_list = MyLinkedList()\n",
" length = 0\n",
" \n",
"\n",
" # Reverse the linked list\n",
" while curr is not None:\n",
" reversed_list.insert_to_front(curr.data)\n",
" length += 1\n",
" curr = curr.next\n",
" \n",
"\n",
" # Compare the reversed list with the original list\n",
" # Only need to compare the first half \n",
" # Only need to compare the first half\n",
" iterations_to_compare_half = length // 2\n",
" curr = self.head\n",
" curr_reversed = reversed_list.head\n",
@@ -158,7 +158,7 @@
"\n",
"\n",
"class TestPalindrome(object):\n",
" \n",
"\n",
" def test_palindrome(self):\n",
" print('Test: Empty list')\n",
" linked_list = MyLinkedList()\n",
@@ -189,13 +189,15 @@
" linked_list.append(2)\n",
" linked_list.append(1)\n",
" assert_equal(linked_list.is_palindrome(), True)\n",
" \n",
"\n",
" print('Success: test_palindrome')\n",
"\n",
"\n",
"def main():\n",
" test = TestPalindrome()\n",
" test.test_palindrome()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]