Python/project_euler
fpringle 9643d3060d
Add solution for Project Euler problem 75. (#3129)
* Added solution for Project Euler problem 75. 

* Added doctest for solution() in project_euler/problem_75/sol1.py

* Update docstring and 0-padding of directory name. Reference: #3256

* More descriptive variable names

* Moved solution explanation to module-level docstring
2020-10-16 16:00:45 +05:30
..
problem_001 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_002 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_003 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_004 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_005 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_006 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_007 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_008 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_009 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_010 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_011 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_012 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_013 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_014 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_015 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_016 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_017 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_018 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_019 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_020 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_021 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_022 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_023 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_024 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_025 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_026 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_027 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_028 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_029 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_030 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_031 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_032 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_033 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_034 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_035 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_036 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_037 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_039 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_040 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_041 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_042 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_043 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_044 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_045 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_046 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_047 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_048 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_049 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_051 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_052 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_053 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_054 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_055 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_056 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_062 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_063 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_067 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_069 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_071 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_072 Add solution for Project Euler problem 72 (#3122) 2020-10-16 15:12:51 +05:30
problem_074 Add solution for Project Euler problem 74. (#3125) 2020-10-16 00:28:15 +05:30
problem_075 Add solution for Project Euler problem 75. (#3129) 2020-10-16 16:00:45 +05:30
problem_076 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_080 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_091 Add solution for Project Euler problem 91. (#3144) 2020-10-16 15:44:06 +05:30
problem_097 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_099 Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
problem_112 Created problem_112.py in project_euler (#2532) 2020-10-03 16:38:56 +08:00
problem_113 Add solution for Project Euler problem 113 (#3109) 2020-10-15 15:29:53 +05:30
problem_119 Added solution for Project Euler problem 119 (#2931) 2020-10-10 23:29:02 +05:30
problem_120 Add Project Euler 120 solution (#2887) 2020-10-06 08:41:15 +05:30
problem_125 Added solution for Project Euler problem 125 (#3073) 2020-10-09 22:41:00 +05:30
problem_173 Add solution for Project Euler problem 173. (#3075) 2020-10-15 15:36:40 +05:30
problem_174 Add solution for Project Euler problem 174. (#3078) 2020-10-16 15:14:09 +05:30
problem_191 Add solution for Project Euler problem 191 (#2875) 2020-10-11 17:59:27 +05:30
problem_234 Fixes: #3163 - Add new solution for problem 234 (#3177) 2020-10-11 23:16:16 +05:30
problem_551 [Project Euler] Fix code style for multiple problems (#3094) 2020-10-10 21:23:17 +05:30
__init__.py Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
project_euler_answers.json Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30
README.md Update README.md for Project Euler (#3256) 2020-10-15 09:47:19 +05:30
validate_solutions.py Rename Project Euler directories and other dependent changes (#3300) 2020-10-15 12:43:28 +05:30

Project Euler

Problems are taken from https://projecteuler.net/.

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Project Euler is ideal for mathematicians who are learning to code.

The solutions will be checked by our automated testing on Travis CI with the help of this script. The efficiency of your code is also checked. You can view the top 10 slowest solutions on Travis CI logs and open a pull request to improve those solutions.

Solution Guidelines

Welcome to TheAlgorithms/Python! Before reading the solution guidelines, make sure you read the whole Contributing Guidelines as it won't be repeated in here. If you have any doubt on the guidelines, please feel free to state it clearly in an issue or ask the community in Gitter. You can use the template we have provided below as your starting point but be sure to read the Coding Style part first.

Coding Style

  • Please maintain consistency in project directory and solution file names. Keep the following points in mind:

    • Create a new directory only for the problems which do not exist yet.
    • If you create a new directory, please create an empty __init__.py file inside it as well.
    • Please name the project directory as problem_<problem_number> where problem_number should be filled with 0s so as to occupy 3 digits. Example: problem_001, problem_002, problem_067, problem_145, and so on.
  • Please provide a link to the problem and other references, if used, in the module-level docstring.

  • All imports should come after the module-level docstring.

  • You can have as many helper functions as you want but there should be one main function called solution which should satisfy the conditions as stated below:

    • It should contain positional argument(s) whose default value is the question input. Example: Please take a look at problem 1 where the question is to Find the sum of all the multiples of 3 or 5 below 1000. In this case the main solution function will be solution(limit: int = 1000).
    • When the solution function is called without any arguments like so: solution(), it should return the answer to the problem.
  • Every function, which includes all the helper functions, if any, and the main solution function, should have doctest in the function docstring along with a brief statement mentioning what the function is about.

    • There should not be a doctest for testing the answer as that is done by our Travis CI build using this script. Keeping in mind the above example of problem 1:
    def solution(limit: int = 1000):
        """
        A brief statement mentioning what the function is about.
    
        You can have a detailed explanation about the solution method in the
        module-level docstring.
    
        >>> solution(1)
        ...
        >>> solution(16)
        ...
        >>> solution(100)
        ...
        """
    

Solution Template

You can use the below template as your starting point but please read the Coding Style first to understand how the template works.

Please change the name of the helper functions accordingly, change the parameter names with a descriptive one, replace the content within [square brackets] (including the brackets) with the appropriate content.

"""
Project Euler Problem [problem number]: [link to the original problem]

... [Entire problem statement] ...

... [Solution explanation - Optional] ...

References [Optional]:
- [Wikipedia link to the topic]
- [Stackoverflow link]
...

"""
import module1
import module2
...

def helper1(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
    """
    A brief statement explaining what the function is about.

    ... A more elaborate description ... [Optional]

    ...
    [Doctest]
    ...

    """
    ...
    # calculations
    ...

    return


# You can have multiple helper functions but the solution function should be
# after all the helper functions ...


def solution(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
    """
    A brief statement mentioning what the function is about.

    You can have a detailed explanation about the solution in the
    module-level docstring.

    ...
    [Doctest as mentioned above]
    ...

    """

    ...
    # calculations
    ...

    return answer


if __name__ == "__main__":
    print(f"{solution() = }")