Example #1
0
    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])
Example #2
0
    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)
Example #3
0
    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))
Example #4
0
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))
Example #5
0
    def test_solves_problem_one(self):
        solver = eulersolver.EulerSolver()

        result = solver.solve_problem_one()

        self.assertEqual(result, 233168)
Example #6
0
    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])
Example #7
0
    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])
Example #8
0
    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)
Example #9
0
    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)