def test_get_factors(self): target1 = 32 answer1 = [[2, 16], [2, 2, 8], [2, 2, 2, 4], [2, 2, 2, 2, 2], [2, 4, 4], [4, 8]] self.assertEqual(sorted(get_factors(target1)), sorted(answer1)) target2 = 12 answer2 = [[2, 6], [2, 2, 3], [3, 4]] self.assertEqual(sorted(get_factors(target2)), sorted(answer2)) self.assertEqual(sorted(get_factors(1)), []) self.assertEqual(sorted(get_factors(37)), [])
def test_get_factors(self): target1 = 32 answer1 = [ [2, 16], [2, 2, 8], [2, 2, 2, 4], [2, 2, 2, 2, 2], [2, 4, 4], [4, 8] ] self.assertEqual(sorted(get_factors(target1)), sorted(answer1)) target2 = 12 answer2 = [ [2, 6], [2, 2, 3], [3, 4] ] self.assertEqual(sorted(get_factors(target2)), sorted(answer2)) self.assertEqual(sorted(get_factors(1)), []) self.assertEqual(sorted(get_factors(37)), [])
from algorithms.backtrack import get_factors, recursive_get_factors n = 12 n2 = 32 print(get_factors(n)) print(get_factors(n2)) print(recursive_get_factors(n)) print(recursive_get_factors(n2)) ### 박제준 4/20