mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-16 14:28:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is this a singly or doubly linked list?\n",
|
||||
" * Singly\n",
|
||||
"* Is this a circular list?\n",
|
||||
@@ -110,17 +109,18 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Node(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, data, next_node=None):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __str__(self):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class LinkedList(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, head=None):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
@@ -128,19 +128,19 @@
|
||||
" def __len__(self):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def insert_to_front(self, data):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def append(self, data, next_node=None):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def find(self, data):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def delete(self, data):\n",
|
||||
" pass\n",
|
||||
" # TODO: Implement me\n",
|
||||
@@ -183,7 +183,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestLinkedList(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_insert_to_front(self):\n",
|
||||
" print('Test: insert_to_front on an empty list')\n",
|
||||
" linked_list = LinkedList(None)\n",
|
||||
@@ -198,9 +198,9 @@
|
||||
" linked_list.insert_to_front('a')\n",
|
||||
" linked_list.insert_to_front('bc')\n",
|
||||
" assert_equal(linked_list.get_all_data(), ['bc', 'a', 10])\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_insert_to_front\\n')\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_append(self):\n",
|
||||
" print('Test: append on an empty list')\n",
|
||||
" linked_list = LinkedList(None)\n",
|
||||
@@ -215,9 +215,9 @@
|
||||
" linked_list.append('a')\n",
|
||||
" linked_list.append('bc')\n",
|
||||
" assert_equal(linked_list.get_all_data(), [10, 'a', 'bc'])\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_append\\n')\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_find(self):\n",
|
||||
" print('Test: find on an empty list')\n",
|
||||
" linked_list = LinkedList(None)\n",
|
||||
@@ -241,9 +241,9 @@
|
||||
" print('Test: find general case with no matches')\n",
|
||||
" node = linked_list.find('aaa')\n",
|
||||
" assert_equal(node, None)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_find\\n')\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_delete(self):\n",
|
||||
" print('Test: delete on an empty list')\n",
|
||||
" linked_list = LinkedList(None)\n",
|
||||
@@ -267,9 +267,9 @@
|
||||
" print('Test: delete general case with no matches')\n",
|
||||
" linked_list.delete('aa')\n",
|
||||
" assert_equal(linked_list.get_all_data(), ['bc', 10])\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_delete\\n')\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_len(self):\n",
|
||||
" print('Test: len on an empty list')\n",
|
||||
" linked_list = LinkedList(None)\n",
|
||||
@@ -281,9 +281,10 @@
|
||||
" linked_list.insert_to_front('a')\n",
|
||||
" linked_list.insert_to_front('bc')\n",
|
||||
" assert_equal(len(linked_list), 3)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_len\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestLinkedList()\n",
|
||||
" test.test_insert_to_front()\n",
|
||||
@@ -291,7 +292,8 @@
|
||||
" test.test_find()\n",
|
||||
" test.test_delete()\n",
|
||||
" test.test_len()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user