diff --git a/README.md b/README.md index e9a590b..bf0c375 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### i-love-lance-janice * Completed in: 34 mins, 26 secs. + +### re-id +* Completed in: 10 mins, 19 secs. diff --git a/extra/re-id/solution.py b/extra/re-id/solution.py new file mode 100644 index 0000000..56bd7c5 --- /dev/null +++ b/extra/re-id/solution.py @@ -0,0 +1,31 @@ +def solution(i): + result = "" + count = 0 + for n in generate_prime(): + result += str(n) + if len(result) >= i + 5: + return result[i:i+5] + +def generate_prime(): + num = 2 + primes = [] + while True: + is_prime = True + for p in primes: + if num % p == 0: + is_prime = False + break + if is_prime: + yield num + primes += [num] + num += 1 + +tests = [ + (0, "23571"), + (1, "35711"), + (3, "71113"), + ] + +for i, o in tests: + result = solution(i) + print (i, result == o, result, o)