# publiccoleifer/project-euler

### Subversion checkout URL

You can clone with HTTPS or Subversion.

 ``` f553adab » coleifer ``` 2009-12-25 Solved 60 1 import math 2 3 def is_prime(n): 4 if n < 2: 5 return False 6 if n != 2 and n % 2 == 0: 7 return False 8 for j in xrange(3, math.sqrt(n) + 1, 2): 9 if n % j == 0: 10 return False 11 return True 12 13 primes = [x for x in xrange(10000) if is_prime(x)] 14 15 def test_nums(group): 16 for i in xrange(len(group)): 17 for j in xrange(len(group)): 18 if j != i: 19 if not (is_prime(int(str(group[i]) + str(group[j]))) and \ 20 is_prime(int(str(group[j]) + str(group[i])))): 21 return False 22 return True 23 24 def run_test(primes): 25 for i in xrange(len(primes) - 5): 26 for j in xrange(i + 1, len(primes)): 27 if not test_nums([primes[i], primes[j]]): 28 continue 29 for k in xrange(j + 1, len(primes)): 30 if not test_nums([primes[i], primes[j], primes[k]]): 31 continue 32 for l in xrange(k + 1, len(primes)): 33 if not test_nums([primes[i], primes[j], primes[k], primes[l]]): 34 continue 35 for m in xrange(l + 1, len(primes)): 36 if not test_nums([primes[i], primes[j], primes[k], primes[l], primes[m]]): 37 continue 38 else: 39 group = [ 40 primes[i], 41 primes[j], 42 primes[k], 43 primes[l], 44 primes[m] 45 ] 46 print group 47 print sum(group) 48 return 49 50 # remove 2 & 5 ``` e4e55d74 » coleifer ``` 2009-12-25 Cleaned up a tiny bit. 51 del(primes[0]) ``` f553adab » coleifer ``` 2009-12-25 Solved 60 52 del(primes[1]) 53 54 run_test(primes)