mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 08:58:02 +00:00
@@ -79,9 +79,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -108,23 +106,21 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_prod_three.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestProdThree(object):\n",
|
||||
"class TestProdThree(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_prod_three(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.max_prod_three, None)\n",
|
||||
" assert_raises(ValueError, solution.max_prod_three, [1, 2])\n",
|
||||
" assert_equal(solution.max_prod_three([5, -2, 3]), -30)\n",
|
||||
" assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
|
||||
" self.assertRaises(TypeError, solution.max_prod_three, None)\n",
|
||||
" self.assertRaises(ValueError, solution.max_prod_three, [1, 2])\n",
|
||||
" self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)\n",
|
||||
" self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
|
||||
" print('Success: test_prod_three')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -163,9 +159,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
|
||||
}
|
||||
|
||||
@@ -145,9 +145,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -198,9 +196,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -212,17 +208,17 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_prod_three.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestProdThree(object):\n",
|
||||
"class TestProdThree(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_prod_three(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.max_prod_three, None)\n",
|
||||
" assert_raises(ValueError, solution.max_prod_three, [1, 2])\n",
|
||||
" assert_equal(solution.max_prod_three([5, -2, 3]), -30)\n",
|
||||
" assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
|
||||
" self.assertRaises(TypeError, solution.max_prod_three, None)\n",
|
||||
" self.assertRaises(ValueError, solution.max_prod_three, [1, 2])\n",
|
||||
" self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)\n",
|
||||
" self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
|
||||
" print('Success: test_prod_three')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -238,9 +234,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -271,9 +265,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"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 TestProdThree(object):
|
||||
class TestProdThree(unittest.TestCase):
|
||||
|
||||
def test_prod_three(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.max_prod_three, None)
|
||||
assert_raises(ValueError, solution.max_prod_three, [1, 2])
|
||||
assert_equal(solution.max_prod_three([5, -2, 3]), -30)
|
||||
assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)
|
||||
self.assertRaises(TypeError, solution.max_prod_three, None)
|
||||
self.assertRaises(ValueError, solution.max_prod_three, [1, 2])
|
||||
self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)
|
||||
self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)
|
||||
print('Success: test_prod_three')
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user