mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 09:28:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||
" * Yes\n",
|
||||
"* If a stack becomes full, we should automatically create one?\n",
|
||||
@@ -112,7 +111,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class StackWithCapacity(Stack):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, top=None, capacity=10):\n",
|
||||
" self.capacity = capacity\n",
|
||||
" self.num_items = 0\n",
|
||||
@@ -133,8 +132,9 @@
|
||||
" def is_full(self):\n",
|
||||
" return self.num_items == self.capacity\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class SetOfStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, capacity):\n",
|
||||
" self.capacity = capacity\n",
|
||||
" self.stacks = []\n",
|
||||
@@ -191,7 +191,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSetOfStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_set_of_stacks(self):\n",
|
||||
" print('Test: Push on an empty stack')\n",
|
||||
" capacity = 2\n",
|
||||
@@ -213,13 +213,15 @@
|
||||
"\n",
|
||||
" print('Test: Pop on no elements')\n",
|
||||
" assert_equal(stacks.pop(), None)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" print('Success: test_set_of_stacks')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestSetOfStacks()\n",
|
||||
" test.test_set_of_stacks()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user