mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-07 09:58:03 +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 (ie not stable, not based on a heap)?\n",
|
||||
" * Yes"
|
||||
]
|
||||
@@ -116,7 +115,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSelectionSort(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_selection_sort(self, func):\n",
|
||||
" print('Empty input')\n",
|
||||
" data = []\n",
|
||||
@@ -132,9 +131,10 @@
|
||||
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
||||
" func(data)\n",
|
||||
" assert_equal(data, sorted(data))\n",
|
||||
" \n",
|
||||
"\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]"
|
||||
@@ -154,7 +154,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestSelectionSort(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_selection_sort(self, func):\n",
|
||||
" print('Empty input')\n",
|
||||
" data = []\n",
|
||||
@@ -170,9 +170,10 @@
|
||||
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
||||
" func(data)\n",
|
||||
" assert_equal(data, sorted(data))\n",
|
||||
" \n",
|
||||
"\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()"
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@ from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestSelectionSort(object):
|
||||
|
||||
|
||||
def test_selection_sort(self, func):
|
||||
print('Empty input')
|
||||
data = []
|
||||
@@ -18,9 +18,10 @@ class TestSelectionSort(object):
|
||||
data = [5, 1, 7, 2, 6, -3, 5, 7, -1]
|
||||
func(data)
|
||||
assert_equal(data, sorted(data))
|
||||
|
||||
|
||||
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