mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 02:48:02 +00:00
@@ -83,9 +83,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -112,23 +110,21 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_max_profit.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMaxProfit(object):\n",
|
||||
"class TestMaxProfit(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_max_profit(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.find_max_profit, None)\n",
|
||||
" assert_raises(ValueError, solution.find_max_profit, [])\n",
|
||||
" assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
|
||||
" assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
|
||||
" self.assertRaises(TypeError, solution.find_max_profit, None)\n",
|
||||
" self.assertRaises(ValueError, solution.find_max_profit, [])\n",
|
||||
" self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
|
||||
" self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
|
||||
" print('Success: test_max_profit')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -167,9 +163,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -90,9 +90,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sys\n",
|
||||
@@ -124,9 +122,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -138,17 +134,17 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_max_profit.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMaxProfit(object):\n",
|
||||
"class TestMaxProfit(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_max_profit(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.find_max_profit, None)\n",
|
||||
" assert_raises(ValueError, solution.find_max_profit, [])\n",
|
||||
" assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
|
||||
" assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
|
||||
" self.assertRaises(TypeError, solution.find_max_profit, None)\n",
|
||||
" self.assertRaises(ValueError, solution.find_max_profit, [])\n",
|
||||
" self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
|
||||
" self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
|
||||
" print('Success: test_max_profit')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -164,9 +160,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -197,9 +191,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestMaxProfit(object):
|
||||
class TestMaxProfit(unittest.TestCase):
|
||||
|
||||
def test_max_profit(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.find_max_profit, None)
|
||||
assert_raises(ValueError, solution.find_max_profit, [])
|
||||
assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1)
|
||||
assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)
|
||||
self.assertRaises(TypeError, solution.find_max_profit, None)
|
||||
self.assertRaises(ValueError, solution.find_max_profit, [])
|
||||
self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)
|
||||
self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)
|
||||
print('Success: test_max_profit')
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user