Fix #13, PEP8-ify notebooks.

This commit is contained in:
Donne Martin 2015-07-11 15:35:22 -04:00
parent 03f04fbc4c
commit 235b6c5abe
6 changed files with 12 additions and 10 deletions

View File

@ -36,7 +36,6 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"See the [HackerRank problem page](https://www.hackerrank.com/challenges/maximizing-xor)." "See the [HackerRank problem page](https://www.hackerrank.com/challenges/maximizing-xor)."
] ]
}, },
@ -105,10 +104,12 @@
" assert_equal(max_xor(10, 15), 7)\n", " assert_equal(max_xor(10, 15), 7)\n",
" print('Success: test_maximizing_xor')\n", " print('Success: test_maximizing_xor')\n",
"\n", "\n",
"\n",
"def main():\n", "def main():\n",
" test = TestMaximingXor()\n", " test = TestMaximingXor()\n",
" test.test_maximizing_xor()\n", " test.test_maximizing_xor()\n",
"\n", "\n",
"\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
" main()" " main()"
] ]

View File

@ -35,7 +35,6 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"See the [HackerRank problem page](https://www.hackerrank.com/challenges/maximizing-xor)." "See the [HackerRank problem page](https://www.hackerrank.com/challenges/maximizing-xor)."
] ]
}, },
@ -124,10 +123,12 @@
" assert_equal(max_xor(10, 15), 7)\n", " assert_equal(max_xor(10, 15), 7)\n",
" print('Success: test_maximizing_xor')\n", " print('Success: test_maximizing_xor')\n",
"\n", "\n",
"\n",
"def main():\n", "def main():\n",
" test = TestMaximingXor()\n", " test = TestMaximingXor()\n",
" test.test_maximizing_xor()\n", " test.test_maximizing_xor()\n",
"\n", "\n",
"\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
" main()" " main()"
] ]

View File

@ -7,9 +7,11 @@ class TestMaximingXor(object):
assert_equal(max_xor(10, 15), 7) assert_equal(max_xor(10, 15), 7)
print('Success: test_maximizing_xor') print('Success: test_maximizing_xor')
def main(): def main():
test = TestMaximingXor() test = TestMaximingXor()
test.test_maximizing_xor() test.test_maximizing_xor()
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -9,9 +9,11 @@ class TestUtopianTree(object):
assert_equal(calc_utopian_tree_height(4), 7) assert_equal(calc_utopian_tree_height(4), 7)
print('Success: test_utopian_tree') print('Success: test_utopian_tree')
def main(): def main():
test = TestUtopianTree() test = TestUtopianTree()
test.test_utopian_tree() test.test_utopian_tree()
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -36,7 +36,6 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"See the [HackerRank problem page](https://www.hackerrank.com/challenges/utopian-tree)." "See the [HackerRank problem page](https://www.hackerrank.com/challenges/utopian-tree)."
] ]
}, },
@ -73,9 +72,6 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# cycles = 0, print 1: base case\n",
"# cycles = 1, print 2: i = 1: 1 * 2\n",
"# cycles = 4, print 7: i = 1: 1 * 2, i = 2: 2 + 1, i = 3: 3 * 2, i = 4: 6 + 1\n",
"def calc_utopian_tree_height(cycles):\n", "def calc_utopian_tree_height(cycles):\n",
" # TODO: Implement me\n", " # TODO: Implement me\n",
" pass" " pass"
@ -110,10 +106,12 @@
" assert_equal(calc_utopian_tree_height(4), 7)\n", " assert_equal(calc_utopian_tree_height(4), 7)\n",
" print('Success: test_utopian_tree')\n", " print('Success: test_utopian_tree')\n",
"\n", "\n",
"\n",
"def main():\n", "def main():\n",
" test = TestUtopianTree()\n", " test = TestUtopianTree()\n",
" test.test_utopian_tree()\n", " test.test_utopian_tree()\n",
"\n", "\n",
"\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
" main()" " main()"
] ]

View File

@ -35,7 +35,6 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"See the [HackerRank problem page](https://www.hackerrank.com/challenges/utopian-tree)." "See the [HackerRank problem page](https://www.hackerrank.com/challenges/utopian-tree)."
] ]
}, },
@ -80,9 +79,6 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# cycles = 0, print 1: base case\n",
"# cycles = 1, print 2: i = 1: 1 * 2\n",
"# cycles = 4, print 7: i = 1: 1 * 2, i = 2: 2 + 1, i = 3: 3 * 2, i = 4: 6 + 1\n",
"def calc_utopian_tree_height(cycles):\n", "def calc_utopian_tree_height(cycles):\n",
" height = 1\n", " height = 1\n",
" if cycles == 0:\n", " if cycles == 0:\n",
@ -131,10 +127,12 @@
" assert_equal(calc_utopian_tree_height(4), 7)\n", " assert_equal(calc_utopian_tree_height(4), 7)\n",
" print('Success: test_utopian_tree')\n", " print('Success: test_utopian_tree')\n",
"\n", "\n",
"\n",
"def main():\n", "def main():\n",
" test = TestUtopianTree()\n", " test = TestUtopianTree()\n",
" test.test_utopian_tree()\n", " test.test_utopian_tree()\n",
"\n", "\n",
"\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
" main()" " main()"
] ]