mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 00:48:03 +00:00
@@ -113,9 +113,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -142,24 +140,22 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_length_longest_path.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSolution(object):\n",
|
||||
"class TestSolution(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_length_longest_path(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.length_longest_path, None)\n",
|
||||
" assert_equal(solution.length_longest_path(''), 0)\n",
|
||||
" self.assertRaises(TypeError, solution.length_longest_path, None)\n",
|
||||
" self.assertEqual(solution.length_longest_path(''), 0)\n",
|
||||
" file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n",
|
||||
" expected = 32\n",
|
||||
" assert_equal(solution.length_longest_path(file_system), expected)\n",
|
||||
" self.assertEqual(solution.length_longest_path(file_system), expected)\n",
|
||||
" print('Success: test_length_longest_path')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -198,9 +194,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
|
||||
}
|
||||
|
||||
@@ -128,9 +128,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -160,9 +158,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -174,18 +170,18 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_length_longest_path.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSolution(object):\n",
|
||||
"class TestSolution(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_length_longest_path(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.length_longest_path, None)\n",
|
||||
" assert_equal(solution.length_longest_path(''), 0)\n",
|
||||
" self.assertRaises(TypeError, solution.length_longest_path, None)\n",
|
||||
" self.assertEqual(solution.length_longest_path(''), 0)\n",
|
||||
" file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n",
|
||||
" expected = 32\n",
|
||||
" assert_equal(solution.length_longest_path(file_system), expected)\n",
|
||||
" self.assertEqual(solution.length_longest_path(file_system), expected)\n",
|
||||
" print('Success: test_length_longest_path')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -201,9 +197,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -234,9 +228,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,15 +1,15 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestSolution(object):
|
||||
class TestSolution(unittest.TestCase):
|
||||
|
||||
def test_length_longest_path(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.length_longest_path, None)
|
||||
assert_equal(solution.length_longest_path(''), 0)
|
||||
self.assertRaises(TypeError, solution.length_longest_path, None)
|
||||
self.assertEqual(solution.length_longest_path(''), 0)
|
||||
file_system = 'dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext'
|
||||
expected = 32
|
||||
assert_equal(solution.length_longest_path(file_system), expected)
|
||||
self.assertEqual(solution.length_longest_path(file_system), expected)
|
||||
print('Success: test_length_longest_path')
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user