Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@

## Dynamic Programming
* [Abbreviation](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/abbreviation.py)
* [All Construct](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/all_construct.py)
* [Bitmask](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/bitmask.py)
* [Catalan Numbers](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/catalan_numbers.py)
* [Climbing Stairs](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/climbing_stairs.py)
Expand Down Expand Up @@ -612,6 +613,7 @@

## Physics
* [N Body Simulation](https://github.com/TheAlgorithms/Python/blob/master/physics/n_body_simulation.py)
* [Newtons Second Law Of Motion](https://github.com/TheAlgorithms/Python/blob/master/physics/newtons_second_law_of_motion.py)

## Project Euler
* Problem 001
Expand Down Expand Up @@ -1018,6 +1020,7 @@
* [Nasa Data](https://github.com/TheAlgorithms/Python/blob/master/web_programming/nasa_data.py)
* [Random Anime Character](https://github.com/TheAlgorithms/Python/blob/master/web_programming/random_anime_character.py)
* [Recaptcha Verification](https://github.com/TheAlgorithms/Python/blob/master/web_programming/recaptcha_verification.py)
* [Reddit](https://github.com/TheAlgorithms/Python/blob/master/web_programming/reddit.py)
* [Search Books By Isbn](https://github.com/TheAlgorithms/Python/blob/master/web_programming/search_books_by_isbn.py)
* [Slack Message](https://github.com/TheAlgorithms/Python/blob/master/web_programming/slack_message.py)
* [Test Fetch Github Info](https://github.com/TheAlgorithms/Python/blob/master/web_programming/test_fetch_github_info.py)
Expand Down
21 changes: 14 additions & 7 deletions project_euler/problem_043/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,34 @@ def is_substring_divisible(num: tuple) -> bool:
>>> is_substring_divisible((1, 4, 0, 6, 3, 5, 7, 2, 8, 9))
True
"""
tests = [2, 3, 5, 7, 11, 13, 17]
if num[3] % 2 != 0:
return False

if (num[2] + num[3] + num[4]) % 3 != 0:
return False

if num[5] % 5 != 0:
return False

tests = [7, 11, 13, 17]
for i, test in enumerate(tests):
if (num[i + 1] * 100 + num[i + 2] * 10 + num[i + 3]) % test != 0:
if (num[i + 4] * 100 + num[i + 5] * 10 + num[i + 6]) % test != 0:
return False
return True


def solution(n: int = 10) -> int:
"""
Returns the sum of all pandigital numbers which pass the
divisiility tests.
divisibility tests.
>>> solution(10)
16695334890
"""
list_nums = [
return sum(
int("".join(map(str, num)))
for num in permutations(range(n))
if is_substring_divisible(num)
]

return sum(list_nums)
)


if __name__ == "__main__":
Expand Down