def test_find_all_even_fibonacci_terms_less_than_10_should_be_2_8(self): solver = eulersolver.EulerSolver() result = solver.find_all_fibonacci_terms_less_than( 10, lambda term: term % 2 == 0) self.assertEqual(list(result), [2, 8])
def test_find_sum_of_even_fibonacci_terms_less_than_4000000(self): solver = eulersolver.EulerSolver() limit = 4000000 result = solver.find_sum_of_even_fibonacci_terms(limit) self.assertEqual(result, 4613732) print(result)
def test_find_all_fibonacci_terms_less_than_4000000_should_not_take_long( self): solver = eulersolver.EulerSolver() result = solver.find_all_fibonacci_terms_less_than(4000000) print(result) print(len(result))
def main(): parser = argparse.ArgumentParser() parser.add_argument('--problem', type=int, help='Number of problem to solve', default=1) args = parser.parse_args() problem_number = args.problem solver = eulersolver.EulerSolver() problem_result = solver.solve(problem_number) print('Result from problem {} is: {}'.format(problem_number, problem_result))
def test_solves_problem_one(self): solver = eulersolver.EulerSolver() result = solver.solve_problem_one() self.assertEqual(result, 233168)
def test_find_all_fibonacci_terms_less_than_10_should_be_1_2_3_5_8(self): solver = eulersolver.EulerSolver() result = solver.find_all_fibonacci_terms_less_than(10) self.assertEqual(list(result), [1, 2, 3, 5, 8])
def test_find_all_fibonacci_terms_less_than_3_should_be_1_2(self): solver = eulersolver.EulerSolver() result = solver.find_all_fibonacci_terms_less_than(3) self.assertEqual(list(result), [1, 2])
def test_find_sum_of_multiples_of_3_5_and_limit_10_should_be_23(self): solver = eulersolver.EulerSolver() result = solver.find_sum_of_multiples(10, [3, 5]) self.assertEqual(result, 23)
def test_find_sum_of_multiples_of_4_and_limit_10_should_be_12(self): solver = eulersolver.EulerSolver() result = solver.find_sum_of_multiples(10, [4]) self.assertEqual(result, 12)