mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Changed sys.maxint to sys.maxsize for Python 3 compatibility.
This commit is contained in:
parent
73924c279a
commit
b57ca00bb2
|
@ -34,10 +34,9 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume this is a stack of ints?\n",
|
"* Can we assume this is a stack of ints?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* If we call this function on an empty stack, can we return max int?\n",
|
"* If we call this function on an empty stack, can we return maxsize?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
|
@ -158,7 +157,7 @@
|
||||||
" assert_equal(stack.pop(), 1)\n",
|
" assert_equal(stack.pop(), 1)\n",
|
||||||
" assert_equal(stack.min(), 5)\n",
|
" assert_equal(stack.min(), 5)\n",
|
||||||
" assert_equal(stack.pop(), 5)\n",
|
" assert_equal(stack.pop(), 5)\n",
|
||||||
" assert_equal(stack.min(), sys.maxint)\n",
|
" assert_equal(stack.min(), sys.maxsize)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Test: Pop empty stack')\n",
|
" print('Test: Pop empty stack')\n",
|
||||||
" assert_equal(stack.pop(), None)\n",
|
" assert_equal(stack.pop(), None)\n",
|
||||||
|
|
|
@ -33,10 +33,9 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume this is a stack of ints?\n",
|
"* Can we assume this is a stack of ints?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* If we call this function on an empty stack, can we return max int?\n",
|
"* If we call this function on an empty stack, can we return sys.maxsize?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
|
@ -127,7 +126,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
" def min(self):\n",
|
" def min(self):\n",
|
||||||
" if self.min_vals.top is None:\n",
|
" if self.min_vals.top is None:\n",
|
||||||
" return sys.maxint\n",
|
" return sys.maxsize\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" return self.min_vals.peek()\n",
|
" return self.min_vals.peek()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -196,7 +195,7 @@
|
||||||
" assert_equal(stack.pop(), 1)\n",
|
" assert_equal(stack.pop(), 1)\n",
|
||||||
" assert_equal(stack.min(), 5)\n",
|
" assert_equal(stack.min(), 5)\n",
|
||||||
" assert_equal(stack.pop(), 5)\n",
|
" assert_equal(stack.pop(), 5)\n",
|
||||||
" assert_equal(stack.min(), sys.maxint)\n",
|
" assert_equal(stack.min(), sys.maxsize)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Test: Pop empty stack')\n",
|
" print('Test: Pop empty stack')\n",
|
||||||
" assert_equal(stack.pop(), None)\n",
|
" assert_equal(stack.pop(), None)\n",
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestStackMin(object):
|
||||||
assert_equal(stack.pop(), 1)
|
assert_equal(stack.pop(), 1)
|
||||||
assert_equal(stack.min(), 5)
|
assert_equal(stack.min(), 5)
|
||||||
assert_equal(stack.pop(), 5)
|
assert_equal(stack.pop(), 5)
|
||||||
assert_equal(stack.min(), sys.maxint)
|
assert_equal(stack.min(), sys.maxsize)
|
||||||
|
|
||||||
print('Test: Pop empty stack')
|
print('Test: Pop empty stack')
|
||||||
assert_equal(stack.pop(), None)
|
assert_equal(stack.pop(), None)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user