mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-15 05:48:03 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
@@ -144,10 +143,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_hanoi')\n",
|
" print('Success: test_hanoi')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestHanoi()\n",
|
" test = TestHanoi()\n",
|
||||||
" test.test_hanoi()\n",
|
" test.test_hanoi()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
@@ -161,10 +160,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_hanoi')\n",
|
" print('Success: test_hanoi')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestHanoi()\n",
|
" test = TestHanoi()\n",
|
||||||
" test.test_hanoi()\n",
|
" test.test_hanoi()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ class TestHanoi(object):
|
|||||||
|
|
||||||
print('Success: test_hanoi')
|
print('Success: test_hanoi')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestHanoi()
|
test = TestHanoi()
|
||||||
test.test_hanoi()
|
test.test_hanoi()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Are the stacks and array a fixed size?\n",
|
"* Are the stacks and array a fixed size?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
@@ -151,6 +150,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_stacks\\n')\n",
|
" print('Success: test_stacks\\n')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" num_stacks = 3\n",
|
" num_stacks = 3\n",
|
||||||
" stack_size = 100\n",
|
" stack_size = 100\n",
|
||||||
@@ -159,6 +159,7 @@
|
|||||||
" test.test_push_on_full(num_stacks, stack_size)\n",
|
" test.test_push_on_full(num_stacks, stack_size)\n",
|
||||||
" test.test_stacks(num_stacks, stack_size)\n",
|
" test.test_stacks(num_stacks, stack_size)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Are the stacks and array a fixed size?\n",
|
"* Are the stacks and array a fixed size?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
@@ -197,6 +196,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_stacks\\n')\n",
|
" print('Success: test_stacks\\n')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" num_stacks = 3\n",
|
" num_stacks = 3\n",
|
||||||
" stack_size = 100\n",
|
" stack_size = 100\n",
|
||||||
@@ -205,6 +205,7 @@
|
|||||||
" test.test_push_on_full(num_stacks, stack_size)\n",
|
" test.test_push_on_full(num_stacks, stack_size)\n",
|
||||||
" test.test_stacks(num_stacks, stack_size)\n",
|
" test.test_stacks(num_stacks, stack_size)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class TestStacks(object):
|
|||||||
|
|
||||||
print('Success: test_stacks\n')
|
print('Success: test_stacks\n')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
num_stacks = 3
|
num_stacks = 3
|
||||||
stack_size = 100
|
stack_size = 100
|
||||||
@@ -42,5 +43,6 @@ def main():
|
|||||||
test.test_push_on_full(num_stacks, stack_size)
|
test.test_push_on_full(num_stacks, stack_size)
|
||||||
test.test_stacks(num_stacks, stack_size)
|
test.test_stacks(num_stacks, stack_size)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Do you expect the methods to be enqueue and dequeue?\n",
|
"* Do you expect the methods to be enqueue and dequeue?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
@@ -158,10 +157,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_queue_from_stacks')\n",
|
" print('Success: test_queue_from_stacks')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestQueueFromStacks()\n",
|
" test = TestQueueFromStacks()\n",
|
||||||
" test.test_queue_from_stacks()\n",
|
" test.test_queue_from_stacks()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Do you expect the methods to be enqueue and dequeue?\n",
|
"* Do you expect the methods to be enqueue and dequeue?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
@@ -197,10 +196,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_queue_from_stacks')\n",
|
" print('Success: test_queue_from_stacks')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestQueueFromStacks()\n",
|
" test = TestQueueFromStacks()\n",
|
||||||
" test.test_queue_from_stacks()\n",
|
" test.test_queue_from_stacks()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ class TestQueueFromStacks(object):
|
|||||||
|
|
||||||
print('Success: test_queue_from_stacks')
|
print('Success: test_queue_from_stacks')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestQueueFromStacks()
|
test = TestQueueFromStacks()
|
||||||
test.test_queue_from_stacks()
|
test.test_queue_from_stacks()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -4,6 +4,7 @@ class Node(object):
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.next = None
|
self.next = None
|
||||||
|
|
||||||
|
|
||||||
class Queue(object):
|
class Queue(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* If there is one item in the list, do you expect the first and last pointers to both point to it?\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",
|
" * Yes\n",
|
||||||
"* If there are no items on the list, do you expect the first and last pointers to be None?\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",
|
" # TODO: Implement me\n",
|
||||||
" pass\n",
|
" pass\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class Queue(object):\n",
|
"class Queue(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self):\n",
|
" def __init__(self):\n",
|
||||||
@@ -157,10 +157,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_end_to_end')\n",
|
" print('Success: test_end_to_end')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestQueue()\n",
|
" test = TestQueue()\n",
|
||||||
" test.test_end_to_end()\n",
|
" test.test_end_to_end()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* If there is one item in the list, do you expect the first and last pointers to both point to it?\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",
|
" * Yes\n",
|
||||||
"* If there are no items on the list, do you expect the first and last pointers to be None?\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.data = data\n",
|
||||||
" self.next = None\n",
|
" self.next = None\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class Queue(object):\n",
|
"class Queue(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self):\n",
|
" def __init__(self):\n",
|
||||||
@@ -221,10 +221,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_end_to_end')\n",
|
" print('Success: test_end_to_end')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestQueue()\n",
|
" test = TestQueue()\n",
|
||||||
" test.test_end_to_end()\n",
|
" test.test_end_to_end()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ class TestQueue(object):
|
|||||||
|
|
||||||
print('Success: test_end_to_end')
|
print('Success: test_end_to_end')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestQueue()
|
test = TestQueue()
|
||||||
test.test_end_to_end()
|
test.test_end_to_end()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* If a stack becomes full, we should automatically create one?\n",
|
"* If a stack becomes full, we should automatically create one?\n",
|
||||||
@@ -109,6 +108,7 @@
|
|||||||
" # TODO: Implement me\n",
|
" # TODO: Implement me\n",
|
||||||
" pass\n",
|
" pass\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class SetOfStacks(object):\n",
|
"class SetOfStacks(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self, capacity):\n",
|
" def __init__(self, capacity):\n",
|
||||||
@@ -173,10 +173,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_set_of_stacks')\n",
|
" print('Success: test_set_of_stacks')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestSetOfStacks()\n",
|
" test = TestSetOfStacks()\n",
|
||||||
" test.test_set_of_stacks()\n",
|
" test.test_set_of_stacks()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
"* Can we assume we already have a stack class that can be used for this problem?\n",
|
||||||
" * Yes\n",
|
" * Yes\n",
|
||||||
"* If a stack becomes full, we should automatically create one?\n",
|
"* If a stack becomes full, we should automatically create one?\n",
|
||||||
@@ -133,6 +132,7 @@
|
|||||||
" def is_full(self):\n",
|
" def is_full(self):\n",
|
||||||
" return self.num_items == self.capacity\n",
|
" return self.num_items == self.capacity\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class SetOfStacks(object):\n",
|
"class SetOfStacks(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self, capacity):\n",
|
" def __init__(self, capacity):\n",
|
||||||
@@ -216,10 +216,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_set_of_stacks')\n",
|
" print('Success: test_set_of_stacks')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestSetOfStacks()\n",
|
" test = TestSetOfStacks()\n",
|
||||||
" test.test_set_of_stacks()\n",
|
" test.test_set_of_stacks()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -27,9 +27,11 @@ class TestSetOfStacks(object):
|
|||||||
|
|
||||||
print('Success: test_set_of_stacks')
|
print('Success: test_set_of_stacks')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestSetOfStacks()
|
test = TestSetOfStacks()
|
||||||
test.test_set_of_stacks()
|
test.test_set_of_stacks()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* When sorted, should the largest element be at the top or bottom?\n",
|
"* When sorted, should the largest element be at the top or bottom?\n",
|
||||||
" * Top\n",
|
" * Top\n",
|
||||||
"* Can you have duplicate values like 5, 5?\n",
|
"* Can you have duplicate values like 5, 5?\n",
|
||||||
@@ -151,10 +150,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_sort_stack')\n",
|
" print('Success: test_sort_stack')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestSortStack()\n",
|
" test = TestSortStack()\n",
|
||||||
" test.test_sort_stack()\n",
|
" test.test_sort_stack()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* When sorted, should the largest element be at the top or bottom?\n",
|
"* When sorted, should the largest element be at the top or bottom?\n",
|
||||||
" * Top\n",
|
" * Top\n",
|
||||||
"* Can you have duplicate values like 5, 5?\n",
|
"* Can you have duplicate values like 5, 5?\n",
|
||||||
@@ -170,10 +169,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_sort_stack')\n",
|
" print('Success: test_sort_stack')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestSortStack()\n",
|
" test = TestSortStack()\n",
|
||||||
" test.test_sort_stack()\n",
|
" test.test_sort_stack()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ class TestSortStack(object):
|
|||||||
|
|
||||||
print('Success: test_sort_stack')
|
print('Success: test_sort_stack')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestSortStack()
|
test = TestSortStack()
|
||||||
test.test_sort_stack()
|
test.test_sort_stack()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -4,6 +4,7 @@ class Node(object):
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.next = None
|
self.next = None
|
||||||
|
|
||||||
|
|
||||||
class Stack(object):
|
class Stack(object):
|
||||||
|
|
||||||
def __init__(self, top=None):
|
def __init__(self, top=None):
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* None"
|
"* None"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -97,6 +96,7 @@
|
|||||||
" # TODO: Implement me\n",
|
" # TODO: Implement me\n",
|
||||||
" pass\n",
|
" pass\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class Stack(object):\n",
|
"class Stack(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self, top=None):\n",
|
" def __init__(self, top=None):\n",
|
||||||
@@ -175,10 +175,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_end_to_end')\n",
|
" print('Success: test_end_to_end')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestStack()\n",
|
" test = TestStack()\n",
|
||||||
" test.test_end_to_end()\n",
|
" test.test_end_to_end()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* None"
|
"* None"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -142,6 +141,7 @@
|
|||||||
" self.data = data\n",
|
" self.data = data\n",
|
||||||
" self.next = None\n",
|
" self.next = None\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"class Stack(object):\n",
|
"class Stack(object):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self, top=None):\n",
|
" def __init__(self, top=None):\n",
|
||||||
@@ -239,10 +239,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_end_to_end')\n",
|
" print('Success: test_end_to_end')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestStack()\n",
|
" test = TestStack()\n",
|
||||||
" test.test_end_to_end()\n",
|
" test.test_end_to_end()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,9 +33,11 @@ class TestStack(object):
|
|||||||
|
|
||||||
print('Success: test_end_to_end')
|
print('Success: test_end_to_end')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestStack()
|
test = TestStack()
|
||||||
test.test_end_to_end()
|
test.test_end_to_end()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
@@ -92,6 +92,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class MyStack(Stack):\n",
|
"class MyStack(Stack):\n",
|
||||||
|
"\n",
|
||||||
" def __init__(self, top=None):\n",
|
" def __init__(self, top=None):\n",
|
||||||
" # TODO: Implement me\n",
|
" # TODO: Implement me\n",
|
||||||
" pass\n",
|
" pass\n",
|
||||||
@@ -133,6 +134,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class TestStackMin(object):\n",
|
"class TestStackMin(object):\n",
|
||||||
|
"\n",
|
||||||
" def test_stack_min(self):\n",
|
" def test_stack_min(self):\n",
|
||||||
" print('Test: Push on empty stack, non-empty stack')\n",
|
" print('Test: Push on empty stack, non-empty stack')\n",
|
||||||
" stack = MyStack()\n",
|
" stack = MyStack()\n",
|
||||||
@@ -164,10 +166,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_stack_min')\n",
|
" print('Success: test_stack_min')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestStackMin()\n",
|
" test = TestStackMin()\n",
|
||||||
" test.test_stack_min()\n",
|
" test.test_stack_min()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class MyStack(Stack):\n",
|
"class MyStack(Stack):\n",
|
||||||
|
"\n",
|
||||||
" def __init__(self, top=None):\n",
|
" def __init__(self, top=None):\n",
|
||||||
" self.min_vals = Stack()\n",
|
" self.min_vals = Stack()\n",
|
||||||
" super(MyStack, self).__init__(top)\n",
|
" super(MyStack, self).__init__(top)\n",
|
||||||
@@ -171,6 +172,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class TestStackMin(object):\n",
|
"class TestStackMin(object):\n",
|
||||||
|
"\n",
|
||||||
" def test_stack_min(self):\n",
|
" def test_stack_min(self):\n",
|
||||||
" print('Test: Push on empty stack, non-empty stack')\n",
|
" print('Test: Push on empty stack, non-empty stack')\n",
|
||||||
" stack = MyStack()\n",
|
" stack = MyStack()\n",
|
||||||
@@ -202,10 +204,12 @@
|
|||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_stack_min')\n",
|
" print('Success: test_stack_min')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestStackMin()\n",
|
" test = TestStackMin()\n",
|
||||||
" test.test_stack_min()\n",
|
" test.test_stack_min()\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from nose.tools import assert_equal
|
|||||||
|
|
||||||
|
|
||||||
class TestStackMin(object):
|
class TestStackMin(object):
|
||||||
|
|
||||||
def test_stack_min(self):
|
def test_stack_min(self):
|
||||||
print('Test: Push on empty stack, non-empty stack')
|
print('Test: Push on empty stack, non-empty stack')
|
||||||
stack = MyStack()
|
stack = MyStack()
|
||||||
@@ -33,9 +34,11 @@ class TestStackMin(object):
|
|||||||
|
|
||||||
print('Success: test_stack_min')
|
print('Success: test_stack_min')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestStackMin()
|
test = TestStackMin()
|
||||||
test.test_stack_min()
|
test.test_stack_min()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user