mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 08:58:02 +00:00
@@ -100,9 +100,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MagicIndex(object):\n",
|
||||
@@ -129,27 +127,25 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_find_magic_index.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestFindMagicIndex(object):\n",
|
||||
"class TestFindMagicIndex(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_find_magic_index(self):\n",
|
||||
" magic_index = MagicIndex()\n",
|
||||
" assert_equal(magic_index.find_magic_index(None), -1)\n",
|
||||
" assert_equal(magic_index.find_magic_index([]), -1)\n",
|
||||
" self.assertEqual(magic_index.find_magic_index(None), -1)\n",
|
||||
" self.assertEqual(magic_index.find_magic_index([]), -1)\n",
|
||||
" array = [-4, -2, 2, 6, 6, 6, 6, 10]\n",
|
||||
" assert_equal(magic_index.find_magic_index(array), 2)\n",
|
||||
" self.assertEqual(magic_index.find_magic_index(array), 2)\n",
|
||||
" array = [-4, -2, 1, 6, 6, 6, 6, 10]\n",
|
||||
" assert_equal(magic_index.find_magic_index(array), 6)\n",
|
||||
" self.assertEqual(magic_index.find_magic_index(array), 6)\n",
|
||||
" array = [-4, -2, 1, 6, 6, 6, 7, 10]\n",
|
||||
" assert_equal(magic_index.find_magic_index(array), -1)\n",
|
||||
" self.assertEqual(magic_index.find_magic_index(array), -1)\n",
|
||||
" print('Success: test_find_magic')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -188,9 +184,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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user