mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
@@ -77,9 +77,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -106,25 +104,23 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_is_power_of_two.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_is_power_of_two(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" assert_equal(solution.is_power_of_two(0), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(1), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(2), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(15), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(16), True)\n",
|
||||
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(0), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(1), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(2), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(15), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(16), True)\n",
|
||||
" print('Success: test_is_power_of_two')\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
|
||||
}
|
||||
|
||||
@@ -98,9 +98,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -123,9 +121,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -137,19 +133,19 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_is_power_of_two.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_is_power_of_two(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" assert_equal(solution.is_power_of_two(0), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(1), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(2), True)\n",
|
||||
" assert_equal(solution.is_power_of_two(15), False)\n",
|
||||
" assert_equal(solution.is_power_of_two(16), True)\n",
|
||||
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(0), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(1), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(2), True)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(15), False)\n",
|
||||
" self.assertEqual(solution.is_power_of_two(16), True)\n",
|
||||
" print('Success: test_is_power_of_two')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -165,9 +161,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -198,9 +192,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,16 +1,16 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestSolution(object):
|
||||
class TestSolution(unittest.TestCase):
|
||||
|
||||
def test_is_power_of_two(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.is_power_of_two, None)
|
||||
assert_equal(solution.is_power_of_two(0), False)
|
||||
assert_equal(solution.is_power_of_two(1), True)
|
||||
assert_equal(solution.is_power_of_two(2), True)
|
||||
assert_equal(solution.is_power_of_two(15), False)
|
||||
assert_equal(solution.is_power_of_two(16), True)
|
||||
self.assertRaises(TypeError, solution.is_power_of_two, None)
|
||||
self.assertEqual(solution.is_power_of_two(0), False)
|
||||
self.assertEqual(solution.is_power_of_two(1), True)
|
||||
self.assertEqual(solution.is_power_of_two(2), True)
|
||||
self.assertEqual(solution.is_power_of_two(15), False)
|
||||
self.assertEqual(solution.is_power_of_two(16), True)
|
||||
print('Success: test_is_power_of_two')
|
||||
|
||||
|
||||
@@ -20,4 +20,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user