mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* If there is one item in the list, do you expect the first and last pointers to both point to it?\n",
|
||||
" * Yes\n",
|
||||
"* If there are no items on the list, do you expect the first and last pointers to be None?\n",
|
||||
@@ -118,13 +117,14 @@
|
||||
"source": [
|
||||
"%%writefile queue_list.py\n",
|
||||
"class Node(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, data):\n",
|
||||
" self.data = data\n",
|
||||
" self.next = None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class Queue(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self):\n",
|
||||
" self.first = None\n",
|
||||
" self.last = None\n",
|
||||
@@ -142,7 +142,7 @@
|
||||
" # Empty list\n",
|
||||
" if self.first is None and self.last is None:\n",
|
||||
" return None\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" # Remove only element from a one element list\n",
|
||||
" elif self.first == self.last:\n",
|
||||
" data = self.first.data\n",
|
||||
@@ -195,7 +195,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestQueue(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" # TODO: It would be better if we had unit tests for each\n",
|
||||
" # method in addition to the following end-to-end test\n",
|
||||
" def test_end_to_end(self):\n",
|
||||
@@ -218,13 +218,15 @@
|
||||
" assert_equal(queue.dequeue(), 2)\n",
|
||||
" assert_equal(queue.dequeue(), 3)\n",
|
||||
" assert_equal(queue.dequeue(), 4)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_end_to_end')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestQueue()\n",
|
||||
" test.test_end_to_end()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user