diff --git a/stacks_queues/stack_min/stack_min_challenge.ipynb b/stacks_queues/stack_min/stack_min_challenge.ipynb index 48c6065..4ea2dc1 100644 --- a/stacks_queues/stack_min/stack_min_challenge.ipynb +++ b/stacks_queues/stack_min/stack_min_challenge.ipynb @@ -103,7 +103,7 @@ " # TODO: Implement me\n", " pass\n", "\n", - " def min(self):\n", + " def minimum(self):\n", " # TODO: Implement me\n", " pass\n", "\n", @@ -146,26 +146,26 @@ " stack = StackMin()\n", " stack.push(5)\n", " assert_equal(stack.peek(), 5)\n", - " assert_equal(stack.min(), 5)\n", + " assert_equal(stack.minimum(), 5)\n", " stack.push(1)\n", " assert_equal(stack.peek(), 1)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " stack.push(3)\n", " assert_equal(stack.peek(), 3)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " stack.push(0)\n", " assert_equal(stack.peek(), 0)\n", - " assert_equal(stack.min(), 0)\n", + " assert_equal(stack.minimum(), 0)\n", "\n", " print('Test: Pop on non-empty stack')\n", " assert_equal(stack.pop(), 0)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " assert_equal(stack.pop(), 3)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " assert_equal(stack.pop(), 1)\n", - " assert_equal(stack.min(), 5)\n", + " assert_equal(stack.minimum(), 5)\n", " assert_equal(stack.pop(), 5)\n", - " assert_equal(stack.min(), sys.maxsize)\n", + " assert_equal(stack.minimum(), sys.maxsize)\n", "\n", " print('Test: Pop empty stack')\n", " assert_equal(stack.pop(), None)\n", diff --git a/stacks_queues/stack_min/stack_min_solution.ipynb b/stacks_queues/stack_min/stack_min_solution.ipynb index d50a358..6a4e10b 100644 --- a/stacks_queues/stack_min/stack_min_solution.ipynb +++ b/stacks_queues/stack_min/stack_min_solution.ipynb @@ -129,23 +129,23 @@ "\n", " def __init__(self, top=None):\n", " super(StackMin, self).__init__(top)\n", - " self.min_vals = Stack()\n", + " self.stack_of_mins = Stack()\n", "\n", - " def min(self):\n", - " if self.min_vals.top is None:\n", + " def minimum(self):\n", + " if self.stack_of_mins.top is None:\n", " return sys.maxsize\n", " else:\n", - " return self.min_vals.peek()\n", + " return self.stack_of_mins.peek()\n", "\n", " def push(self, data):\n", " super(StackMin, self).push(data)\n", - " if data < self.min():\n", - " self.min_vals.push(data)\n", + " if data < self.minimum():\n", + " self.stack_of_mins.push(data)\n", "\n", " def pop(self):\n", " data = super(StackMin, self).pop()\n", - " if data == self.min():\n", - " self.min_vals.pop()\n", + " if data == self.minimum():\n", + " self.stack_of_mins.pop()\n", " return data" ] }, @@ -184,26 +184,26 @@ " stack = StackMin()\n", " stack.push(5)\n", " assert_equal(stack.peek(), 5)\n", - " assert_equal(stack.min(), 5)\n", + " assert_equal(stack.minimum(), 5)\n", " stack.push(1)\n", " assert_equal(stack.peek(), 1)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " stack.push(3)\n", " assert_equal(stack.peek(), 3)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " stack.push(0)\n", " assert_equal(stack.peek(), 0)\n", - " assert_equal(stack.min(), 0)\n", + " assert_equal(stack.minimum(), 0)\n", "\n", " print('Test: Pop on non-empty stack')\n", " assert_equal(stack.pop(), 0)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " assert_equal(stack.pop(), 3)\n", - " assert_equal(stack.min(), 1)\n", + " assert_equal(stack.minimum(), 1)\n", " assert_equal(stack.pop(), 1)\n", - " assert_equal(stack.min(), 5)\n", + " assert_equal(stack.minimum(), 5)\n", " assert_equal(stack.pop(), 5)\n", - " assert_equal(stack.min(), sys.maxsize)\n", + " assert_equal(stack.minimum(), sys.maxsize)\n", "\n", " print('Test: Pop empty stack')\n", " assert_equal(stack.pop(), None)\n", diff --git a/stacks_queues/stack_min/test_stack_min.py b/stacks_queues/stack_min/test_stack_min.py index 290c898..1fb354d 100644 --- a/stacks_queues/stack_min/test_stack_min.py +++ b/stacks_queues/stack_min/test_stack_min.py @@ -8,26 +8,26 @@ class TestStackMin(object): stack = StackMin() stack.push(5) assert_equal(stack.peek(), 5) - assert_equal(stack.min(), 5) + assert_equal(stack.minimum(), 5) stack.push(1) assert_equal(stack.peek(), 1) - assert_equal(stack.min(), 1) + assert_equal(stack.minimum(), 1) stack.push(3) assert_equal(stack.peek(), 3) - assert_equal(stack.min(), 1) + assert_equal(stack.minimum(), 1) stack.push(0) assert_equal(stack.peek(), 0) - assert_equal(stack.min(), 0) + assert_equal(stack.minimum(), 0) print('Test: Pop on non-empty stack') assert_equal(stack.pop(), 0) - assert_equal(stack.min(), 1) + assert_equal(stack.minimum(), 1) assert_equal(stack.pop(), 3) - assert_equal(stack.min(), 1) + assert_equal(stack.minimum(), 1) assert_equal(stack.pop(), 1) - assert_equal(stack.min(), 5) + assert_equal(stack.minimum(), 5) assert_equal(stack.pop(), 5) - assert_equal(stack.min(), sys.maxsize) + assert_equal(stack.minimum(), sys.maxsize) print('Test: Pop empty stack') assert_equal(stack.pop(), None)