Fix #13, PEP8-ify notebooks.

This commit is contained in:
Donne Martin 2015-07-11 15:39:59 -04:00
parent 4566d1a803
commit 3712839cc9
26 changed files with 139 additions and 92 deletions

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
" * Yes"
]
@ -144,10 +143,12 @@
"\n",
" print('Success: test_hanoi')\n",
"\n",
"\n",
"def main():\n",
" test = TestHanoi()\n",
" test.test_hanoi()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
" * Yes"
]
@ -161,10 +160,12 @@
"\n",
" print('Success: test_hanoi')\n",
"\n",
"\n",
"def main():\n",
" test = TestHanoi()\n",
" test.test_hanoi()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -30,9 +30,11 @@ class TestHanoi(object):
print('Success: test_hanoi')
def main():
test = TestHanoi()
test.test_hanoi()
if __name__ == '__main__':
main()

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* Are the stacks and array a fixed size?\n",
" * Yes"
]
@ -151,6 +150,7 @@
"\n",
" print('Success: test_stacks\\n')\n",
"\n",
"\n",
"def main():\n",
" num_stacks = 3\n",
" stack_size = 100\n",
@ -159,6 +159,7 @@
" test.test_push_on_full(num_stacks, stack_size)\n",
" test.test_stacks(num_stacks, stack_size)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* Are the stacks and array a fixed size?\n",
" * Yes"
]
@ -197,6 +196,7 @@
"\n",
" print('Success: test_stacks\\n')\n",
"\n",
"\n",
"def main():\n",
" num_stacks = 3\n",
" stack_size = 100\n",
@ -205,6 +205,7 @@
" test.test_push_on_full(num_stacks, stack_size)\n",
" test.test_stacks(num_stacks, stack_size)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -34,6 +34,7 @@ class TestStacks(object):
print('Success: test_stacks\n')
def main():
num_stacks = 3
stack_size = 100
@ -42,5 +43,6 @@ def main():
test.test_push_on_full(num_stacks, stack_size)
test.test_stacks(num_stacks, stack_size)
if __name__ == '__main__':
main()

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* Do you expect the methods to be enqueue and dequeue?\n",
" * Yes\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
@ -158,10 +157,12 @@
"\n",
" print('Success: test_queue_from_stacks')\n",
"\n",
"\n",
"def main():\n",
" test = TestQueueFromStacks()\n",
" test.test_queue_from_stacks()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* Do you expect the methods to be enqueue and dequeue?\n",
" * Yes\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
@ -197,10 +196,12 @@
"\n",
" print('Success: test_queue_from_stacks')\n",
"\n",
"\n",
"def main():\n",
" test = TestQueueFromStacks()\n",
" test.test_queue_from_stacks()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -29,9 +29,11 @@ class TestQueueFromStacks(object):
print('Success: test_queue_from_stacks')
def main():
test = TestQueueFromStacks()
test.test_queue_from_stacks()
if __name__ == '__main__':
main()

View File

@ -4,6 +4,7 @@ class Node(object):
self.data = data
self.next = None
class Queue(object):
def __init__(self):

View File

@ -35,7 +35,6 @@
"source": [
"## Constraints\n",
"\n",
"* If there is one item in the list, do you expect the first and last pointers to both point to it?\n",
" * Yes\n",
"* If there are no items on the list, do you expect the first and last pointers to be None?\n",
@ -92,6 +91,7 @@
" # TODO: Implement me\n",
" pass\n",
"\n",
"\n",
"class Queue(object):\n",
"\n",
" def __init__(self):\n",
@ -157,10 +157,12 @@
"\n",
" print('Success: test_end_to_end')\n",
"\n",
"\n",
"def main():\n",
" test = TestQueue()\n",
" test.test_end_to_end()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* If there is one item in the list, do you expect the first and last pointers to both point to it?\n",
" * Yes\n",
"* If there are no items on the list, do you expect the first and last pointers to be None?\n",
@ -123,6 +122,7 @@
" self.data = data\n",
" self.next = None\n",
"\n",
"\n",
"class Queue(object):\n",
"\n",
" def __init__(self):\n",
@ -221,10 +221,12 @@
"\n",
" print('Success: test_end_to_end')\n",
"\n",
"\n",
"def main():\n",
" test = TestQueue()\n",
" test.test_end_to_end()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -28,9 +28,11 @@ class TestQueue(object):
print('Success: test_end_to_end')
def main():
test = TestQueue()
test.test_end_to_end()
if __name__ == '__main__':
main()

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
" * Yes\n",
"* If a stack becomes full, we should automatically create one?\n",
@ -109,6 +108,7 @@
" # TODO: Implement me\n",
" pass\n",
"\n",
"\n",
"class SetOfStacks(object):\n",
"\n",
" def __init__(self, capacity):\n",
@ -173,10 +173,12 @@
"\n",
" print('Success: test_set_of_stacks')\n",
"\n",
"\n",
"def main():\n",
" test = TestSetOfStacks()\n",
" test.test_set_of_stacks()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can we assume we already have a stack class that can be used for this problem?\n",
" * Yes\n",
"* If a stack becomes full, we should automatically create one?\n",
@ -133,6 +132,7 @@
" def is_full(self):\n",
" return self.num_items == self.capacity\n",
"\n",
"\n",
"class SetOfStacks(object):\n",
"\n",
" def __init__(self, capacity):\n",
@ -216,10 +216,12 @@
"\n",
" print('Success: test_set_of_stacks')\n",
"\n",
"\n",
"def main():\n",
" test = TestSetOfStacks()\n",
" test.test_set_of_stacks()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -27,9 +27,11 @@ class TestSetOfStacks(object):
print('Success: test_set_of_stacks')
def main():
test = TestSetOfStacks()
test.test_set_of_stacks()
if __name__ == '__main__':
main()

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* When sorted, should the largest element be at the top or bottom?\n",
" * Top\n",
"* Can you have duplicate values like 5, 5?\n",
@ -151,10 +150,12 @@
"\n",
" print('Success: test_sort_stack')\n",
"\n",
"\n",
"def main():\n",
" test = TestSortStack()\n",
" test.test_sort_stack()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,7 +33,6 @@
"source": [
"## Constraints\n",
"\n",
"* When sorted, should the largest element be at the top or bottom?\n",
" * Top\n",
"* Can you have duplicate values like 5, 5?\n",
@ -170,10 +169,12 @@
"\n",
" print('Success: test_sort_stack')\n",
"\n",
"\n",
"def main():\n",
" test = TestSortStack()\n",
" test.test_sort_stack()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -31,9 +31,11 @@ class TestSortStack(object):
print('Success: test_sort_stack')
def main():
test = TestSortStack()
test.test_sort_stack()
if __name__ == '__main__':
main()

View File

@ -4,6 +4,7 @@ class Node(object):
self.data = data
self.next = None
class Stack(object):
def __init__(self, top=None):

View File

@ -35,7 +35,6 @@
"source": [
"## Constraints\n",
"\n",
"* None"
]
},
@ -97,6 +96,7 @@
" # TODO: Implement me\n",
" pass\n",
"\n",
"\n",
"class Stack(object):\n",
"\n",
" def __init__(self, top=None):\n",
@ -175,10 +175,12 @@
"\n",
" print('Success: test_end_to_end')\n",
"\n",
"\n",
"def main():\n",
" test = TestStack()\n",
" test.test_end_to_end()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* None"
]
},
@ -142,6 +141,7 @@
" self.data = data\n",
" self.next = None\n",
"\n",
"\n",
"class Stack(object):\n",
"\n",
" def __init__(self, top=None):\n",
@ -239,10 +239,12 @@
"\n",
" print('Success: test_end_to_end')\n",
"\n",
"\n",
"def main():\n",
" test = TestStack()\n",
" test.test_end_to_end()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -33,9 +33,11 @@ class TestStack(object):
print('Success: test_end_to_end')
def main():
test = TestStack()
test.test_end_to_end()
if __name__ == '__main__':
main()

View File

@ -92,6 +92,7 @@
"\n",
"\n",
"class MyStack(Stack):\n",
"\n",
" def __init__(self, top=None):\n",
" # TODO: Implement me\n",
" pass\n",
@ -133,6 +134,7 @@
"\n",
"\n",
"class TestStackMin(object):\n",
"\n",
" def test_stack_min(self):\n",
" print('Test: Push on empty stack, non-empty stack')\n",
" stack = MyStack()\n",
@ -164,10 +166,12 @@
"\n",
" print('Success: test_stack_min')\n",
"\n",
"\n",
"def main():\n",
" test = TestStackMin()\n",
" test.test_stack_min()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -120,6 +120,7 @@
"\n",
"\n",
"class MyStack(Stack):\n",
"\n",
" def __init__(self, top=None):\n",
" self.min_vals = Stack()\n",
" super(MyStack, self).__init__(top)\n",
@ -171,6 +172,7 @@
"\n",
"\n",
"class TestStackMin(object):\n",
"\n",
" def test_stack_min(self):\n",
" print('Test: Push on empty stack, non-empty stack')\n",
" stack = MyStack()\n",
@ -202,10 +204,12 @@
"\n",
" print('Success: test_stack_min')\n",
"\n",
"\n",
"def main():\n",
" test = TestStackMin()\n",
" test.test_stack_min()\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]

View File

@ -2,6 +2,7 @@ from nose.tools import assert_equal
class TestStackMin(object):
def test_stack_min(self):
print('Test: Push on empty stack, non-empty stack')
stack = MyStack()
@ -33,9 +34,11 @@ class TestStackMin(object):
print('Success: test_stack_min')
def main():
test = TestStackMin()
test.test_stack_min()
if __name__ == '__main__':
main()