mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-19 07:48:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -122,9 +121,14 @@
|
||||
"\n",
|
||||
" print('Success: test_insertion_sort')\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestInsertionSort()\n",
|
||||
" test.test_insertion_sort()"
|
||||
" test.test_insertion_sort()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -145,9 +144,14 @@
|
||||
"\n",
|
||||
" print('Success: test_insertion_sort')\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestInsertionSort()\n",
|
||||
" test.test_insertion_sort()"
|
||||
" test.test_insertion_sort()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -21,6 +21,11 @@ class TestInsertionSort(object):
|
||||
|
||||
print('Success: test_insertion_sort')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
def main():
|
||||
test = TestInsertionSort()
|
||||
test.test_insertion_sort()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -122,10 +121,12 @@
|
||||
"\n",
|
||||
" print('Success: test_merge_sort')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestMergeSort()\n",
|
||||
" test.test_merge_sort()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
" r += 1\n",
|
||||
" return result\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def merge_sort(data):\n",
|
||||
" if len(data) < 2:\n",
|
||||
" return data\n",
|
||||
@@ -168,10 +169,12 @@
|
||||
"\n",
|
||||
" print('Success: test_merge_sort')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestMergeSort()\n",
|
||||
" test.test_merge_sort()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -20,9 +20,11 @@ class TestMergeSort(object):
|
||||
|
||||
print('Success: test_merge_sort')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestMergeSort()
|
||||
test.test_merge_sort()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient (ie not in-place)?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -121,6 +120,7 @@
|
||||
"\n",
|
||||
" print('Success: test_quick_sort\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestQuickSort()\n",
|
||||
" test.test_quick_sort(quick_sort)\n",
|
||||
@@ -131,6 +131,7 @@
|
||||
" # in the solutions file\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
"source": [
|
||||
"from __future__ import division\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def quick_sort(data):\n",
|
||||
" if len(data) < 2:\n",
|
||||
" return data\n",
|
||||
@@ -118,9 +119,7 @@
|
||||
"source": [
|
||||
"## Pythonic-Code\n",
|
||||
"\n",
|
||||
"From http://stackoverflow.com/questions/18262306/quick-sort-with-python\n",
|
||||
"\n",
|
||||
"The following code is very concise, although it might be a little difficult to read:"
|
||||
"The following code from [Stack Overflow](http://stackoverflow.com/questions/18262306/quick-sort-with-python) is very concise, although it might be a little difficult to read:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -185,6 +184,7 @@
|
||||
"\n",
|
||||
" print('Success: test_quick_sort\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestQuickSort()\n",
|
||||
" test.test_quick_sort(quick_sort)\n",
|
||||
@@ -195,6 +195,7 @@
|
||||
" # in the solutions file\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -20,6 +20,7 @@ class TestQuickSort(object):
|
||||
|
||||
print('Success: test_quick_sort\n')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestQuickSort()
|
||||
test.test_quick_sort(quick_sort)
|
||||
@@ -30,5 +31,6 @@ def main():
|
||||
# in the solutions file
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient (ie not stable, not based on a heap)?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -135,6 +134,7 @@
|
||||
"\n",
|
||||
" print('Success: test_selection_sort\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestSelectionSort()\n",
|
||||
" test.test_selection_sort(selection_sort)\n",
|
||||
@@ -145,6 +145,7 @@
|
||||
" # in the solutions file\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Is a naiive solution sufficient (ie not stable, not based on a heap)?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -91,6 +90,7 @@
|
||||
" min_index = i\n",
|
||||
" return min_index\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def swap(data, i, j):\n",
|
||||
" if (i != j):\n",
|
||||
" data[i], data[j] = data[j], data[i]"
|
||||
@@ -173,6 +173,7 @@
|
||||
"\n",
|
||||
" print('Success: test_selection_sort\\n')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestSelectionSort()\n",
|
||||
" test.test_selection_sort(selection_sort)\n",
|
||||
@@ -183,6 +184,7 @@
|
||||
" # in the solutions file\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -21,6 +21,7 @@ class TestSelectionSort(object):
|
||||
|
||||
print('Success: test_selection_sort\n')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestSelectionSort()
|
||||
test.test_selection_sort(selection_sort)
|
||||
@@ -31,5 +32,6 @@ def main():
|
||||
# in the solutions file
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user