mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 02:48:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -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()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -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()
|
||||||
@@ -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()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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()"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user