Created
September 30, 2020 21:41
-
-
Save thejevans/132006ac60e96afc981fe35464772680 to your computer and use it in GitHub Desktop.
MPMP15: Prime Pairs Naive Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1, 2, 3, 4, 7, 6, 5, 8, 9): [3, 5, 7, 11, 13, 11, 13, 17] | |
(1, 2, 3, 4, 9, 8, 5, 6, 7): [3, 5, 7, 13, 17, 13, 11, 13] | |
(1, 2, 3, 8, 5, 6, 7, 4, 9): [3, 5, 11, 13, 11, 13, 11, 13] | |
(1, 2, 3, 8, 9, 4, 7, 6, 5): [3, 5, 11, 17, 13, 11, 13, 11] | |
(1, 2, 5, 6, 7, 4, 3, 8, 9): [3, 7, 11, 13, 11, 7, 11, 17] | |
(1, 2, 5, 6, 7, 4, 9, 8, 3): [3, 7, 11, 13, 11, 13, 17, 11] | |
(1, 2, 9, 4, 3, 8, 5, 6, 7): [3, 11, 13, 7, 11, 13, 11, 13] | |
(1, 2, 9, 4, 7, 6, 5, 8, 3): [3, 11, 13, 11, 13, 11, 13, 11] | |
(1, 2, 9, 8, 3, 4, 7, 6, 5): [3, 11, 17, 11, 7, 11, 13, 11] | |
(1, 2, 9, 8, 5, 6, 7, 4, 3): [3, 11, 17, 13, 11, 13, 11, 7] | |
(1, 4, 3, 2, 9, 8, 5, 6, 7): [5, 7, 5, 11, 17, 13, 11, 13] | |
(1, 4, 3, 8, 9, 2, 5, 6, 7): [5, 7, 11, 17, 11, 7, 11, 13] | |
(1, 4, 7, 6, 5, 2, 3, 8, 9): [5, 11, 13, 11, 7, 5, 11, 17] | |
(1, 4, 7, 6, 5, 2, 9, 8, 3): [5, 11, 13, 11, 7, 11, 17, 11] | |
(1, 4, 7, 6, 5, 8, 3, 2, 9): [5, 11, 13, 11, 13, 11, 5, 11] | |
(1, 4, 7, 6, 5, 8, 9, 2, 3): [5, 11, 13, 11, 13, 17, 11, 5] | |
(1, 4, 9, 2, 3, 8, 5, 6, 7): [5, 13, 11, 5, 11, 13, 11, 13] | |
(1, 4, 9, 8, 3, 2, 5, 6, 7): [5, 13, 17, 11, 5, 7, 11, 13] | |
(1, 6, 5, 2, 3, 8, 9, 4, 7): [7, 11, 7, 5, 11, 17, 13, 11] | |
(1, 6, 5, 2, 9, 8, 3, 4, 7): [7, 11, 7, 11, 17, 11, 7, 11] | |
(1, 6, 5, 8, 3, 2, 9, 4, 7): [7, 11, 13, 11, 5, 11, 13, 11] | |
(1, 6, 5, 8, 9, 2, 3, 4, 7): [7, 11, 13, 17, 11, 5, 7, 11] | |
(1, 6, 7, 4, 3, 2, 5, 8, 9): [7, 13, 11, 7, 5, 7, 13, 17] | |
(1, 6, 7, 4, 3, 2, 9, 8, 5): [7, 13, 11, 7, 5, 11, 17, 13] | |
(1, 6, 7, 4, 3, 8, 5, 2, 9): [7, 13, 11, 7, 11, 13, 7, 11] | |
(1, 6, 7, 4, 3, 8, 9, 2, 5): [7, 13, 11, 7, 11, 17, 11, 7] | |
(1, 6, 7, 4, 9, 2, 3, 8, 5): [7, 13, 11, 13, 11, 5, 11, 13] | |
(1, 6, 7, 4, 9, 2, 5, 8, 3): [7, 13, 11, 13, 11, 7, 13, 11] | |
(1, 6, 7, 4, 9, 8, 3, 2, 5): [7, 13, 11, 13, 17, 11, 5, 7] | |
(1, 6, 7, 4, 9, 8, 5, 2, 3): [7, 13, 11, 13, 17, 13, 7, 5] | |
(3, 2, 1, 4, 7, 6, 5, 8, 9): [5, 3, 5, 11, 13, 11, 13, 17] | |
(3, 2, 1, 4, 9, 8, 5, 6, 7): [5, 3, 5, 13, 17, 13, 11, 13] | |
(3, 2, 1, 6, 5, 8, 9, 4, 7): [5, 3, 7, 11, 13, 17, 13, 11] | |
(3, 2, 1, 6, 7, 4, 9, 8, 5): [5, 3, 7, 13, 11, 13, 17, 13] | |
(3, 2, 5, 8, 9, 4, 1, 6, 7): [5, 7, 13, 17, 13, 5, 7, 13] | |
(3, 2, 9, 8, 5, 6, 1, 4, 7): [5, 11, 17, 13, 11, 7, 5, 11] | |
(3, 4, 1, 2, 9, 8, 5, 6, 7): [7, 5, 3, 11, 17, 13, 11, 13] | |
(3, 4, 7, 6, 1, 2, 5, 8, 9): [7, 11, 13, 7, 3, 7, 13, 17] | |
(3, 4, 7, 6, 1, 2, 9, 8, 5): [7, 11, 13, 7, 3, 11, 17, 13] | |
(3, 4, 9, 8, 5, 2, 1, 6, 7): [7, 13, 17, 13, 7, 3, 7, 13] | |
(3, 8, 5, 2, 1, 6, 7, 4, 9): [11, 13, 7, 3, 7, 13, 11, 13] | |
(3, 8, 5, 2, 9, 4, 1, 6, 7): [11, 13, 7, 11, 13, 5, 7, 13] | |
(3, 8, 5, 6, 1, 2, 9, 4, 7): [11, 13, 11, 7, 3, 11, 13, 11] | |
(3, 8, 5, 6, 7, 4, 1, 2, 9): [11, 13, 11, 13, 11, 5, 3, 11] | |
(3, 8, 9, 2, 1, 4, 7, 6, 5): [11, 17, 11, 3, 5, 11, 13, 11] | |
(3, 8, 9, 2, 5, 6, 1, 4, 7): [11, 17, 11, 7, 11, 7, 5, 11] | |
(3, 8, 9, 4, 1, 2, 5, 6, 7): [11, 17, 13, 5, 3, 7, 11, 13] | |
(3, 8, 9, 4, 7, 6, 1, 2, 5): [11, 17, 13, 11, 13, 7, 3, 7] | |
(5, 2, 1, 6, 7, 4, 3, 8, 9): [7, 3, 7, 13, 11, 7, 11, 17] | |
(5, 2, 3, 8, 9, 4, 1, 6, 7): [7, 5, 11, 17, 13, 5, 7, 13] | |
(5, 2, 9, 8, 3, 4, 1, 6, 7): [7, 11, 17, 11, 7, 5, 7, 13] | |
(5, 6, 1, 2, 3, 8, 9, 4, 7): [11, 7, 3, 5, 11, 17, 13, 11] | |
(5, 6, 1, 2, 9, 8, 3, 4, 7): [11, 7, 3, 11, 17, 11, 7, 11] | |
(5, 6, 7, 4, 1, 2, 3, 8, 9): [11, 13, 11, 5, 3, 5, 11, 17] | |
(5, 8, 3, 2, 1, 6, 7, 4, 9): [13, 11, 5, 3, 7, 13, 11, 13] | |
(5, 8, 3, 2, 9, 4, 1, 6, 7): [13, 11, 5, 11, 13, 5, 7, 13] | |
(5, 8, 3, 4, 7, 6, 1, 2, 9): [13, 11, 7, 11, 13, 7, 3, 11] | |
(5, 8, 3, 4, 9, 2, 1, 6, 7): [13, 11, 7, 13, 11, 3, 7, 13] | |
(5, 8, 9, 2, 3, 4, 1, 6, 7): [13, 17, 11, 5, 7, 5, 7, 13] | |
(5, 8, 9, 4, 3, 2, 1, 6, 7): [13, 17, 13, 7, 5, 3, 7, 13] | |
(7, 4, 1, 6, 5, 2, 3, 8, 9): [11, 5, 7, 11, 7, 5, 11, 17] | |
(7, 4, 1, 6, 5, 8, 3, 2, 9): [11, 5, 7, 11, 13, 11, 5, 11] | |
(7, 4, 3, 2, 1, 6, 5, 8, 9): [11, 7, 5, 3, 7, 11, 13, 17] | |
(7, 4, 3, 8, 5, 6, 1, 2, 9): [11, 7, 11, 13, 11, 7, 3, 11] | |
(7, 6, 1, 2, 5, 8, 3, 4, 9): [13, 7, 3, 7, 13, 11, 7, 13] | |
(7, 6, 1, 4, 3, 2, 5, 8, 9): [13, 7, 5, 7, 5, 7, 13, 17] | |
(7, 6, 1, 4, 3, 8, 5, 2, 9): [13, 7, 5, 7, 11, 13, 7, 11] | |
(7, 6, 5, 2, 1, 4, 3, 8, 9): [13, 11, 7, 3, 5, 7, 11, 17] | |
(7, 6, 5, 8, 3, 2, 1, 4, 9): [13, 11, 13, 11, 5, 3, 5, 13] | |
(7, 6, 5, 8, 3, 4, 1, 2, 9): [13, 11, 13, 11, 7, 5, 3, 11] | |
there are 70 solutions not including mirrored permutations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
primes = set([2, 3, 5, 7, 11, 13, 17]) | |
def pair_sums(permutation): | |
sums = [] | |
for i in range(len(permutation) - 1): | |
sums.append(sum(permutation[i:i+2])) | |
return sums | |
count = 0 | |
for permutation in permutations(range(1,10)): | |
if permutation[0] > permutation[-1]: | |
continue | |
sums = pair_sums(permutation) | |
if set(sums).issubset(primes): | |
print(f'{permutation}: {sums}') | |
count += 1 | |
print(f'there are {count} solutions not including mirrored permutations') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment