mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 10:58:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Are the stacks and array a fixed size?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -107,7 +106,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Stacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def __init__(self, num_stacks, stack_size):\n",
|
||||
" self.num_stacks = num_stacks\n",
|
||||
" self.stack_size = stack_size\n",
|
||||
@@ -129,7 +128,7 @@
|
||||
" if self.stack_pointers[stack_index] == -1:\n",
|
||||
" raise Exception('Stack is empty')\n",
|
||||
" else:\n",
|
||||
" array_index = self.abs_index(stack_index) \n",
|
||||
" array_index = self.abs_index(stack_index)\n",
|
||||
" data = self.stack_array[array_index]\n",
|
||||
" self.stack_array[array_index] = None\n",
|
||||
" self.stack_pointers[stack_index] -= 1\n",
|
||||
@@ -166,7 +165,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestStacks(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" @raises(Exception)\n",
|
||||
" def test_pop_on_empty(self, num_stacks, stack_size):\n",
|
||||
" print('Test: Pop on empty stack')\n",
|
||||
@@ -197,14 +196,16 @@
|
||||
"\n",
|
||||
" print('Success: test_stacks\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" num_stacks = 3\n",
|
||||
" stack_size = 100 \n",
|
||||
" stack_size = 100\n",
|
||||
" test = TestStacks()\n",
|
||||
" test.test_pop_on_empty(num_stacks, stack_size)\n",
|
||||
" test.test_push_on_full(num_stacks, stack_size)\n",
|
||||
" test.test_stacks(num_stacks, stack_size)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user