def test_dynamic_approach2():
    class _s:
        o = ''

    def p(o):
        _s.o = o

    i = iter(['3', '3', '000', '000', '000'])
    solution.input = lambda: next(i)
    solution.print = p
    solution.solution2()
    print(_s.o)
    assert _s.o == 6
예제 #2
0
def run_unit_tests(testcases, expected_results):
	for n in range(len(testcases)):
		print(f"Running tests for problem{n+1}...")
		tests, expected = testcases[n], expected_results[n]
		for i in range(len(tests)):
			if n +1 == 1:  #test problem 1
				actual = solution.solution1(tests[i])
			if n + 1 == 2:  # test problem 2
				actual = solution.solution2(tests[i])

			if actual == expected[i]:
				print(f"Test{i+1} passed")
			else:
				print(f"Test{i+1} failed")
				print(actual)
예제 #3
0
 def test_case_2(self):
     result = solution.solution2([1, 2, 3, 4, 4])
     self.assertEqual(result, 4)
예제 #4
0
 def test_case_4(self):
     result = solution.solution2([1, 2, 3, 4, 2])
     self.assertEqual(result, 2)
예제 #5
0
def run_both(testcases):
	print(f"Running end-to-end tests...")
	for i in range(len(testcases)):
		test = testcases[i]
		if test == solution.solution2(solution.solution1(test)):
			print(f"End to End Test{i+1} passed")
예제 #6
0
        if self.data:

            if data < self.data:
                if self.left is None:
                    self.left = Node(data)
                else:
                    self.left.insert(data)

            elif data > self.data:
                if self.right is None:
                    self.right = Node(data)
                else:
                    self.right.insert(data)

        else:
            self.data = data


root = Node(1)
root.insert(2)
root.insert(5)
root.insert(6)
root.insert(23)
root.insert(3)
root.insert(29)
root.insert(12)
root.insert(24)
root.insert(13)

print(solution2(root))
예제 #7
0
 def test_case_6(self):
     result = solution.solution2([25, 7, 11, 14, 24, 5, 17, 35, 8, 36], 4)
     self.assertEqual(result, [24, 5, 17, 35, 8, 36, 25, 7, 11, 14])
예제 #8
0
 def test_case_5(self):
     result = solution.solution2([0, 1, 2, 3, 4], 1)
     self.assertEqual(result, [1, 2, 3, 4, 0])