diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
| commit | 1879caa1dd80cb11dd62403663917ad4bf7cc68e (patch) | |
| tree | ea41c6dd83a9f9bbfe0a891237674342de92d533 /python/043-sub_string_divisibility.py | |
| parent | 6b16d921543a62d880171791d39bcc58560785fa (diff) | |
| download | project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.gz project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.bz2 project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.zip | |
rename all file with 3 zero padding
Diffstat (limited to 'python/043-sub_string_divisibility.py')
| -rw-r--r-- | python/043-sub_string_divisibility.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/043-sub_string_divisibility.py b/python/043-sub_string_divisibility.py new file mode 100644 index 0000000..16164c1 --- /dev/null +++ b/python/043-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) |
