From 76da9ec98d502d911c1168db41d823284cb9bbe3 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sun, 21 Feb 2016 16:20:29 -0500 Subject: [PATCH] Polish n stacks solution --- .../n_stacks/n_stacks_solution.ipynb | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/stacks_queues/n_stacks/n_stacks_solution.ipynb b/stacks_queues/n_stacks/n_stacks_solution.ipynb index c5cd113..1f248a6 100644 --- a/stacks_queues/n_stacks/n_stacks_solution.ipynb +++ b/stacks_queues/n_stacks/n_stacks_solution.ipynb @@ -119,20 +119,18 @@ " def push(self, stack_index, data):\n", " if self.stack_pointers[stack_index] == self.stack_size - 1:\n", " raise Exception('Stack is full')\n", - " else:\n", - " self.stack_pointers[stack_index] += 1\n", - " array_index = self.abs_index(stack_index)\n", - " self.stack_array[array_index] = data\n", + " self.stack_pointers[stack_index] += 1\n", + " array_index = self.abs_index(stack_index)\n", + " self.stack_array[array_index] = data\n", "\n", " def pop(self, stack_index):\n", " if self.stack_pointers[stack_index] == -1:\n", " raise Exception('Stack is empty')\n", - " else:\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", - " return data" + " 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", + " return data" ] }, { @@ -237,21 +235,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.4.3" } }, "nbformat": 4,