Last active
August 29, 2015 14:10
-
-
Save veiset/7dc4fcb6a4099c2691fc to your computer and use it in GitHub Desktop.
This file contains 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
MIN, MAX = 10, 100 | |
primes = [str(prime) for prime | |
in range(MIN, MAX) | |
if all(prime%i != 0 for i in range(2, prime))] | |
def takeLowest(n, primes): | |
for i, prime in enumerate(primes): | |
if prime.startswith(n): | |
return primes.pop(i) | |
raise Exception("No such number exists") | |
def findn(n, primes): | |
result = str(n) | |
while len(result) < n: | |
result += takeLowest(result[-1], primes)[1] | |
return result | |
print findn(9, primes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment