From 0bf56834c0ffc8f3bf69b337251d11548e5d6968 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Wed, 26 Oct 2016 07:57:51 -0400 Subject: [PATCH] Update stack min challenge (#108) Updates constraints and solution. --- stacks_queues/sort_stack/sort_stack_challenge.ipynb | 4 +++- stacks_queues/sort_stack/sort_stack_solution.ipynb | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stacks_queues/sort_stack/sort_stack_challenge.ipynb b/stacks_queues/sort_stack/sort_stack_challenge.ipynb index 597bc9d..ef3ba7e 100644 --- a/stacks_queues/sort_stack/sort_stack_challenge.ipynb +++ b/stacks_queues/sort_stack/sort_stack_challenge.ipynb @@ -39,6 +39,8 @@ "* Can you have duplicate values like 5, 5?\n", " * Yes\n", "* Can we assume we already have a stack class that can be used for this problem?\n", + " * Yes\n", + "* Can we assume this fits memory?\n", " * Yes" ] }, @@ -191,7 +193,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4, diff --git a/stacks_queues/sort_stack/sort_stack_solution.ipynb b/stacks_queues/sort_stack/sort_stack_solution.ipynb index 828e5ef..a4e3fe4 100644 --- a/stacks_queues/sort_stack/sort_stack_solution.ipynb +++ b/stacks_queues/sort_stack/sort_stack_solution.ipynb @@ -38,6 +38,8 @@ "* Can you have duplicate values like 5, 5?\n", " * Yes\n", "* Can we assume we already have a stack class that can be used for this problem?\n", + " * Yes\n", + "* Can we assume this fits memory?\n", " * Yes" ] }, @@ -87,8 +89,7 @@ }, "outputs": [], "source": [ - "%run ../stack/stack.py\n", - "%load ../stack/stack.py" + "%run ../stack/stack.py" ] }, { @@ -108,7 +109,7 @@ " if buff.is_empty() or temp >= buff.peek():\n", " buff.push(temp)\n", " else:\n", - " while not buff.is_empty() and buff.peek() > temp:\n", + " while not buff.is_empty() and temp < buff.peek():\n", " self.push(buff.pop())\n", " buff.push(temp)\n", " return buff" @@ -135,7 +136,7 @@ " buff = MyStack()\n", " while not self.is_empty():\n", " temp = self.pop()\n", - " while not buff.is_empty() and buff.peek() > temp:\n", + " while not buff.is_empty() and temp < buff.peek():\n", " self.push(buff.pop())\n", " buff.push(temp)\n", " return buff" @@ -252,7 +253,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4,