Issues (956)

solutions/problem1.py (2 issues)

1
"""
2
Project Euler Problem 1: Multiples of 3 and 5
3
=============================================
4
5
.. module:: solutions.problem1
6
   :synopsis: My solution to problem #1.
7
8
The source code for this problem can be
9
`found here <https://bitbucket.org/nekedome/project-euler/src/master/solutions/problem1.py>`_.
10
11
Problem Statement
12
#################
13
14
If we list all the natural numbers below :math:`10` that are multiples of :math:`3` or :math:`5`, we get :math:`3, 5, 6`
0 ignored issues
show
This line is too long as per the coding-style (120/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
15
and :math:`9`. The sum of these multiples is :math:`23`.
16
17
Find the sum of all the multiples of :math:`3` or :math:`5` below :math:`1000`.
18
19
Solution Discussion
20
###################
21
22
Nothing sophisticated here, explicitly perform the computation.
23
24
Solution Implementation
25
#######################
26
27
.. literalinclude:: ../../solutions/problem1.py
28
   :language: python
29
   :lines: 33-
30
"""
31
32
33
def solve():
34
    """ Compute the answer to Project Euler's problem #1 """
35
    num_range = range(1, 1000)
36
    valid = lambda n: n % 3 == 0 or n % 5 == 0  # number must be a multiple of 3 OR 5
37
    numbers = [i for i in num_range if valid(i)]
38
    answer = sum(numbers)
39
    return answer
40
41
42
expected_answer = 233168
0 ignored issues
show
Coding Style Naming introduced by
The name expected_answer does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
43