      "collapsed": false
     },
     "outputs": [],
     "source": [
      "print('Push on an empty stack')\n",
      "capacity = 2\n",
      "stacks = SetOfStacks(capacity)\n",
      "stacks.push(3)\n",
      "print('Push on a non-empty stack')\n",
      "stacks.push(5)\n",
      "print('Push on a capacity stack to create a new one')\n",
      "stacks.push('a')\n",
      "print('Pop on a one element stack to destroy it')\n",
      "print(stacks.pop())\n",
      "print('Pop general case')\n",
      "print(stacks.pop())\n",
      "print(stacks.pop())\n",
      "print('Pop on no elements')\n",
      "print(stacks.pop())"
     ]
    }
   ],
   "metadata": {
    "kernelspec": {
 
</s> remove    "outputs": [],
 </s> add    "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test: Push on an empty stack\n",
      "Test: Push on a non-empty stack\n",
      "Test: Push on a capacity stack to create a new one\n",
      "Test: Pop on a one element stack to destroy it\n",
      "Test: Pop general case\n",
      "Test: Pop on no elements\n",
      "Success: test_set_of_stacks\n"
     ]
    }
   ], </s> remove     "* Can we assume we have a Stack class to use?\n",
 </s> add     "*Problem statements are often intentionally ambiguous.  Identifying constraints and stating assumptions can help to ensure you code the intended solution.*\n",
    "\n",
    "* Can we assume we already have a stack class that can be used for this problem?\n",
    "    * Yes\n",
    "* If a stack becomes full, we should automatically create one?\n",
    "    * Yes\n",
    "* If a stack becomes empty, should we delete it?\n", </s> remove     "* [Clarifying Questions](#Clarifying-Questions)\n",
 </s> add     "* [Constraints and Assumptions](#Constraints-and-Assumptions)\n", </s> remove     "## Clarifying Questions\n",
 </s> add     "## Constraints and Assumptions\n",
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
    "from nose.tools import assert_equal\n",
    "\n",
    "class Test(object):\n",
    "    def test_set_of_stacks(self):\n",
    "        print('Test: Push on an empty stack')\n",
    "        capacity = 2\n",
    "        stacks = SetOfStacks(capacity)\n",
    "        stacks.push(3)\n",
    "\n",
    "        print('Test: Push on a non-empty stack')\n",
    "        stacks.push(5)\n",
    "\n",
    "        print('Test: Push on a capacity stack to create a new one')\n",
    "        stacks.push('a')\n",
    "\n",
    "        print('Test: Pop on a one element stack to destroy it')\n",
    "        assert_equal(stacks.pop(), 'a')\n",
    "\n",
    "        print('Test: Pop general case')\n",
    "        assert_equal(stacks.pop(), 5)\n",
    "        assert_equal(stacks.pop(), 3)\n",
    "\n",
    "        print('Test: Pop on no elements')\n",
    "        assert_equal(stacks.pop(), None)\n",
    "        \n",
    "        print('Success: test_set_of_stacks')\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    test = Test()\n",
    "    test.test_set_of_stacks()"
     ]
    }
   ],
   "metadata": {
    "kernelspec": {
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Reworked notebook: Added more detail to constraints and test cases.  Reworked unit test. 
stacks-queues/set-of-stacks.ipynb