def problem58():
    primes = 0
    for shell in count(1):
        # We only need to check the 4 cornes and there is an easy formula to
        # generate all of them
        primes += sum(1 for i in range(1, 4)
                      if isPrime((2 * shell + 1) ** 2 - 2 * i * shell))
        if primes / (4 * shell + 1) < 0.10:
            return 2 * shell + 1
def problem49():
    primes = primesUpTo(10000)
    for a in dropwhile(lambda x: x <= 1487, primes):
        # the bound comes from wanting c = 2b - a ≤ 10000
        for b in dropwhile(lambda x: x <= a, primes):
            if b >= (10000 + a) / 2:
                break
            c = b + (b - a)
            # Do the same digits first since I think that is the most time
            # consuming part
            if sameDigits(a, b) and sameDigits(b, c) and isPrime(c):
                return int(str(a) + str(b) + str(c))
def problem50():	
	GOAL = 10**6
	listOfPrimes = primesUpTo(GOAL)
	recordLength = 21
	maxPrime = 953
	for index in count():
		for length, running in enumerate(accumulate(listOfPrimes[index:])):
			if length + 1 > recordLength and isPrime(running):
				recordLength = length + 1
				maxPrime = running
			if running > GOAL:
				break
		# If there is no hope, break out
		if sum(listOfPrimes[index: index+recordLength]) > GOAL:
			break
	return maxPrime
def problem27():
    record = 0
    ab = 0
    checker = Orderedlist(primesUpTo(1998))
    # We know there is a record of 80
    # this removes many possibilities for low values of b
    # since the most number of primes for f(n) is b-1
    for b in checker[80:1000]:
        for p1 in checker[0:1000 + b + 1]:
            a = p1 - b - 1
            n = 2
            p2 = a + p1 + (2 * n - 1)
            while isPrime(abs(p2)):
                n += 1
                p2 = a + p2 + (2 * n - 1)
            if n > record:
                record = n
                ab = a * b
    return ab
 def primeCheck(i,s):
     return isPrime(int(m.replace(i, s)))
def remarkable(p,q):
	return isPrime(int(str(q) + str(p))) and isPrime(int(str(p) + str(q)))