mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Polish set of stacks challenge
This commit is contained in:
parent
ba14cb0417
commit
2b92f51a4e
|
@ -36,7 +36,7 @@
|
||||||
"\n",
|
"\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\n",
|
" * Yes\n",
|
||||||
"* If a stack becomes full, we should automatically create one?\n",
|
"* If a stack becomes full, should automatically create one?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* If a stack becomes empty, should we delete it?\n",
|
"* If a stack becomes empty, should we delete it?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
"* Push and pop on an empty stack\n",
|
"* Push and pop on an empty stack\n",
|
||||||
"* Push and pop on a non-empty stack\n",
|
"* Push and pop on a non-empty stack\n",
|
||||||
"* Push on a capacity stack to create a new one\n",
|
"* Push on a capacity stack to create a new one\n",
|
||||||
"* Pop on a one element stack to destroy it"
|
"* Pop on a stack to destroy it"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -151,8 +151,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
" def test_set_of_stacks(self):\n",
|
" def test_set_of_stacks(self):\n",
|
||||||
" print('Test: Push on an empty stack')\n",
|
" print('Test: Push on an empty stack')\n",
|
||||||
" capacity = 2\n",
|
" stacks = SetOfStacks(capacity=2)\n",
|
||||||
" stacks = SetOfStacks(capacity)\n",
|
|
||||||
" stacks.push(3)\n",
|
" stacks.push(3)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Test: Push on a non-empty stack')\n",
|
" print('Test: Push on a non-empty stack')\n",
|
||||||
|
@ -161,7 +160,7 @@
|
||||||
" print('Test: Push on a capacity stack to create a new one')\n",
|
" print('Test: Push on a capacity stack to create a new one')\n",
|
||||||
" stacks.push('a')\n",
|
" stacks.push('a')\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Test: Pop on a one element stack to destroy it')\n",
|
" print('Test: Pop on a stack to destroy it')\n",
|
||||||
" assert_equal(stacks.pop(), 'a')\n",
|
" assert_equal(stacks.pop(), 'a')\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Test: Pop general case')\n",
|
" print('Test: Pop general case')\n",
|
||||||
|
@ -195,21 +194,21 @@
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 2",
|
"display_name": "Python 3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python2"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 2
|
"version": 3
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "2.7.10"
|
"version": "3.4.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user