diff --git a/stacks_queues/stack/stack.py b/stacks_queues/stack/stack.py index b9357f7..0dd986c 100644 --- a/stacks_queues/stack/stack.py +++ b/stacks_queues/stack/stack.py @@ -11,8 +11,7 @@ class Stack(object): self.top = top def push(self, data): - node = Node(data, self.top) - self.top = node + self.top = Node(data, self.top) def pop(self): if self.top is None: diff --git a/stacks_queues/stack/stack_challenge.ipynb b/stacks_queues/stack/stack_challenge.ipynb index 29be60f..3e33074 100644 --- a/stacks_queues/stack/stack_challenge.ipynb +++ b/stacks_queues/stack/stack_challenge.ipynb @@ -35,7 +35,10 @@ "source": [ "## Constraints\n", "\n", - "* None" + "* If we pop on an empty stack, do we return None?\n", + " * Yes\n", + "* Can we assume this fits memory?\n", + " * Yes" ] }, { @@ -197,21 +200,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.5.0" } }, "nbformat": 4, diff --git a/stacks_queues/stack/stack_solution.ipynb b/stacks_queues/stack/stack_solution.ipynb index d3896ce..5301c5a 100644 --- a/stacks_queues/stack/stack_solution.ipynb +++ b/stacks_queues/stack/stack_solution.ipynb @@ -34,7 +34,10 @@ "source": [ "## Constraints\n", "\n", - "* None" + "* If we pop on an empty stack, do we return None?\n", + " * Yes\n", + "* Can we assume this fits memory?\n", + " * Yes" ] }, { @@ -148,8 +151,7 @@ " self.top = top\n", "\n", " def push(self, data):\n", - " node = Node(data, self.top)\n", - " self.top = node\n", + " self.top = Node(data, self.top)\n", "\n", " def pop(self):\n", " if self.top is None:\n", @@ -319,7 +321,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4,