Polish set of stacks challenge and solution (#73)

Update constraints, algorithm discussion, and code.
This commit is contained in:
Donne Martin
2016-06-21 05:30:14 -04:00
committed by GitHub
parent e71b280082
commit 7f338b0e64
3 changed files with 25 additions and 14 deletions

View File

@@ -36,9 +36,15 @@
"\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
" * Yes\n",
"* Are all stack bound by the same capacity?\n",
" * Yes\n",
"* If a stack becomes full, should automatically create one?\n",
" * Yes\n",
"* If a stack becomes empty, should we delete it?\n",
" * Yes\n",
"* If we pop on an empty stack, should we return None?\n",
" * Yes\n",
"* Can we assume this fits memory?\n",
" * Yes"
]
},
@@ -111,7 +117,7 @@
"\n",
"class SetOfStacks(object):\n",
"\n",
" def __init__(self, capacity):\n",
" def __init__(self, indiv_stack_capacity):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
@@ -151,7 +157,7 @@
"\n",
" def test_set_of_stacks(self):\n",
" print('Test: Push on an empty stack')\n",
" stacks = SetOfStacks(capacity=2)\n",
" stacks = SetOfStacks(indiv_stack_capacity=2)\n",
" stacks.push(3)\n",
"\n",
" print('Test: Push on a non-empty stack')\n",
@@ -208,7 +214,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.5.0"
}
},
"nbformat": 4,