diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-11 18:42:52 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-11 18:42:52 +0200 |
| commit | 7b624de8e3e3637a07364f992c1d7e4185e4a872 (patch) | |
| tree | fdb9b0c3f9185b267f9f7bfb9cb4b0e4cdd8cc16 /python/43-sub_string_divisibility.py | |
| download | project_euler-7b624de8e3e3637a07364f992c1d7e4185e4a872.tar.gz project_euler-7b624de8e3e3637a07364f992c1d7e4185e4a872.tar.bz2 project_euler-7b624de8e3e3637a07364f992c1d7e4185e4a872.zip | |
initial commit
Diffstat (limited to 'python/43-sub_string_divisibility.py')
| -rw-r--r-- | python/43-sub_string_divisibility.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/43-sub_string_divisibility.py b/python/43-sub_string_divisibility.py new file mode 100644 index 0000000..16164c1 --- /dev/null +++ b/python/43-sub_string_divisibility.py @@ -0,0 +1,24 @@ +from itertools import permutations + + +first_primes = [2, 3, 5, 7, 11, 13, 17] +all_pandigital = [int(''.join(map(lambda n: str(n), x))) for x in permutations(range(10)) if x[0] != 0] + + +def property_check(nb): + str_nb = str(nb) + indexs = [1, 2, 3] + for i in range(7): + if int(''.join([str_nb[i] for i in indexs])) % first_primes[i] != 0: + return False + indexs = [x + 1 for x in indexs] + + return True + + +nb_sum = 0 +for nb in all_pandigital: + if property_check(nb): + nb_sum += nb + +print(nb_sum) |
