mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-03-04 14:48:45 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Do you expect the methods to be enqueue and dequeue?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
@@ -92,7 +91,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class QueueFromStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self):\n",
|
||||
" # TODO: Implement me\n",
|
||||
" pass\n",
|
||||
@@ -131,7 +130,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestQueueFromStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_queue_from_stacks(self):\n",
|
||||
" print('Test: Dequeue on empty stack')\n",
|
||||
" queue = QueueFromStacks()\n",
|
||||
@@ -141,7 +140,7 @@
|
||||
" print('Test: Enqueue on non-empty stack')\n",
|
||||
" print('Test: Multiple enqueue in a row')\n",
|
||||
" num_items = 3\n",
|
||||
" for i in range (0, num_items):\n",
|
||||
" for i in range(0, num_items):\n",
|
||||
" queue.enqueue(i)\n",
|
||||
"\n",
|
||||
" print('Test: Dequeue on non-empty stack')\n",
|
||||
@@ -158,10 +157,12 @@
|
||||
"\n",
|
||||
" print('Success: test_queue_from_stacks')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestQueueFromStacks()\n",
|
||||
" test.test_queue_from_stacks()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Do you expect the methods to be enqueue and dequeue?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
@@ -121,7 +120,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class QueueFromStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self):\n",
|
||||
" self.left_stack = Stack()\n",
|
||||
" self.right_stack = Stack()\n",
|
||||
@@ -170,7 +169,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestQueueFromStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_queue_from_stacks(self):\n",
|
||||
" print('Test: Dequeue on empty stack')\n",
|
||||
" queue = QueueFromStacks()\n",
|
||||
@@ -180,7 +179,7 @@
|
||||
" print('Test: Enqueue on non-empty stack')\n",
|
||||
" print('Test: Multiple enqueue in a row')\n",
|
||||
" num_items = 3\n",
|
||||
" for i in range (0, num_items):\n",
|
||||
" for i in range(0, num_items):\n",
|
||||
" queue.enqueue(i)\n",
|
||||
"\n",
|
||||
" print('Test: Dequeue on non-empty stack')\n",
|
||||
@@ -197,10 +196,12 @@
|
||||
"\n",
|
||||
" print('Success: test_queue_from_stacks')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestQueueFromStacks()\n",
|
||||
" test.test_queue_from_stacks()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@ from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestQueueFromStacks(object):
|
||||
|
||||
|
||||
def test_queue_from_stacks(self):
|
||||
print('Test: Dequeue on empty stack')
|
||||
queue = QueueFromStacks()
|
||||
@@ -12,7 +12,7 @@ class TestQueueFromStacks(object):
|
||||
print('Test: Enqueue on non-empty stack')
|
||||
print('Test: Multiple enqueue in a row')
|
||||
num_items = 3
|
||||
for i in range (0, num_items):
|
||||
for i in range(0, num_items):
|
||||
queue.enqueue(i)
|
||||
|
||||
print('Test: Dequeue on non-empty stack')
|
||||
@@ -29,9 +29,11 @@ class TestQueueFromStacks(object):
|
||||
|
||||
print('Success: test_queue_from_stacks')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestQueueFromStacks()
|
||||
test.test_queue_from_stacks()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user