diff --git a/online_judges/utopian_tree/test_utopian_tree.py b/online_judges/utopian_tree/test_utopian_tree.py index 2af3cd2..6d11808 100644 --- a/online_judges/utopian_tree/test_utopian_tree.py +++ b/online_judges/utopian_tree/test_utopian_tree.py @@ -4,9 +4,10 @@ from nose.tools import assert_equal class TestUtopianTree(object): def test_utopian_tree(self): - assert_equal(calc_utopian_tree_height(0), 1) - assert_equal(calc_utopian_tree_height(1), 2) - assert_equal(calc_utopian_tree_height(4), 7) + solution = Solution() + assert_equal(solution.calc_utopian_tree_height(0), 1) + assert_equal(solution.calc_utopian_tree_height(1), 2) + assert_equal(solution.calc_utopian_tree_height(4), 7) print('Success: test_utopian_tree') diff --git a/online_judges/utopian_tree/utopian_tree_challenge.ipynb b/online_judges/utopian_tree/utopian_tree_challenge.ipynb index e09696e..a91cbc2 100644 --- a/online_judges/utopian_tree/utopian_tree_challenge.ipynb +++ b/online_judges/utopian_tree/utopian_tree_challenge.ipynb @@ -72,9 +72,11 @@ }, "outputs": [], "source": [ - "def calc_utopian_tree_height(cycles):\n", - " # TODO: Implement me\n", - " pass" + "class Solution(object):\n", + "\n", + " def calc_utopian_tree_height(self, cycles):\n", + " # TODO: Implement me\n", + " pass" ] }, { @@ -101,9 +103,10 @@ "class TestUtopianTree(object):\n", "\n", " def test_utopian_tree(self):\n", - " assert_equal(calc_utopian_tree_height(0), 1)\n", - " assert_equal(calc_utopian_tree_height(1), 2)\n", - " assert_equal(calc_utopian_tree_height(4), 7)\n", + " solution = Solution()\n", + " assert_equal(solution.calc_utopian_tree_height(0), 1)\n", + " assert_equal(solution.calc_utopian_tree_height(1), 2)\n", + " assert_equal(solution.calc_utopian_tree_height(4), 7)\n", " print('Success: test_utopian_tree')\n", "\n", "\n", @@ -128,21 +131,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.5.0" } }, "nbformat": 4, diff --git a/online_judges/utopian_tree/utopian_tree_solution.ipynb b/online_judges/utopian_tree/utopian_tree_solution.ipynb index d9c7af0..d8ee1b3 100644 --- a/online_judges/utopian_tree/utopian_tree_solution.ipynb +++ b/online_judges/utopian_tree/utopian_tree_solution.ipynb @@ -79,16 +79,18 @@ }, "outputs": [], "source": [ - "def calc_utopian_tree_height(cycles):\n", - " height = 1\n", - " if cycles == 0:\n", - " return height\n", - " for i in range(1, cycles+1):\n", - " if i % 2 == 1:\n", - " height *= 2\n", - " else:\n", - " height += 1\n", - " return height" + "class Solution(object):\n", + "\n", + " def calc_utopian_tree_height(self, cycles):\n", + " height = 1\n", + " if cycles == 0:\n", + " return height\n", + " for i in range(1, cycles+1):\n", + " if i % 2 == 1:\n", + " height *= 2\n", + " else:\n", + " height += 1\n", + " return height" ] }, { @@ -122,9 +124,10 @@ "class TestUtopianTree(object):\n", "\n", " def test_utopian_tree(self):\n", - " assert_equal(calc_utopian_tree_height(0), 1)\n", - " assert_equal(calc_utopian_tree_height(1), 2)\n", - " assert_equal(calc_utopian_tree_height(4), 7)\n", + " solution = Solution()\n", + " assert_equal(solution.calc_utopian_tree_height(0), 1)\n", + " assert_equal(solution.calc_utopian_tree_height(1), 2)\n", + " assert_equal(solution.calc_utopian_tree_height(4), 7)\n", " print('Success: test_utopian_tree')\n", "\n", "\n", @@ -159,21 +162,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.5.0" } }, "nbformat": 4,