def test_primes_list_bw(): assert my_function.primes_list_bw(18) == [2, 3, 5, 7, 11, 13, 17] assert my_function.primes_list_bw(100) == [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ] assert my_function.primes_list_bw(1000) == [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 ]
#Python 3.7.x #https://projecteuler.net/problem=51 """ There is a deliberate logical error in the code. Do you understand Python for a long time to find her. """ from my_function import primes_list_bw from my_function import isPrime s1 = primes_list_bw(150000) s2 = primes_list_bw(100000) ss = set(s1) - set(s2) st = [x for x in ss if len(str(x)) - len(set(str(x))) >= 2] for num in st: string = str(num) count_index_item = [(i, x) for i, x in enumerate(string) if string.count(x) > 1] temp_index_item = [i for i in enumerate(string)] for (indx1, itm1) in count_index_item: for (indx2, itm2) in count_index_item: for (indx3, itm3) in count_index_item: if indx1 != indx2 and indx1 != indx3 and indx2 != indx3\ and itm1 == itm2 == itm3: temp_arry = set() for z in range(0, 10): temp_index_item[indx1] = (indx1, str(z)) temp_index_item[indx2] = (indx2, str(z)) temp_index_item[indx3] = (indx3, str(z)) tmp_num = '' for k in temp_index_item: tmp_num += k[1]
#Python 3.7.4 #https://projecteuler.net/problem=7 """ There is a deliberate error in the code. Do you understand Python for a long time to find her """ from my_function import primes_list_bw print ('Result of the problem 7:', primes_list_bw(10001)[10001])
#Python 3.7.x #https://projecteuler.net/problem=41 """ There is a deliberate error in the code. Do you understand Python for a long time to find her. """ from my_function import primes_list_bw result_arry = {0} primes_arry = primes_list_bw(10000000) for i in [x for x in primes_arry if len(str(x)) == 7]: temp_string = ''.join(sorted(str(i))) if temp_string == '1234567': result_arry.add(i) print('Result of the problem 41:', len(result_arry))
#Python 3.7.4 #https://projecteuler.net/problem=10 """ There is a deliberate error in the code. Do you understand Python for a long time to find her """ from my_function import primes_list_bw print('Result of the problem 10:', len(primes_list_bw(1999999)))
#Python 3.7.x #https://projecteuler.net/problem=27 """ There is a deliberate logical error in the code. Do you understand Python for a long time to find her. """ from my_function import primes_list_bw prmn = primes_list_bw(1000) lng = 0 for b in prmn: for a in range(-999, 1000, 2): img = b n = 0 while img in prmn: n += 1 img = n * 2 + a * n + b if img in prmn: if n > lng: lng = n rslt = a * b print('Result of the problem 27:', rslt)
#Python 3.7.x #https://projecteuler.net/problem=37 """ There is a deliberate logical error in the code. Do you understand Python for a long time to find her.""" from my_function import primes_list_bw from my_function import isPrime arry = primes_list_bw(739399) result_arry = set() for k in arry: if k > 10: kn = len(str(k)) for i in range(1, kn): if isPrime(int(str(k)[:-i])) or isPrime(int(str(k)[i:])): break elif len(str(k)[i:]) == 1: result_arry.add(k) if len(result_arry) == 11: break print('Result of the problem 37:', sum(result_arry))
#Python 3.7.4 #https://projecteuler.net/problem=3 """ There is a deliberate error in the code. Do you understand Python for a long time to find her. """ from my_function import factorization from my_function import primes_list_bw num = 600851475143 fact_arry = factorization(num) primes_list = primes_list_bw(max(fact_arry)) print('Result of the problem 3:', max(set(fact_arry) & set(primes_list)))
#Python 3.7.x #https://projecteuler.net/problem=50 """ There is a deliberate error in the code. Do you understand Python for a long time to find her. """ from my_function import primes_list_bw arry_primes = primes_list_bw(1000000) arry_temp = arry_primes[:-170:-1] arry_prime_max = [] for x in arry_temp: v = 3 while v < 8: z = x summ = 0 for y in arry_primes[v:550]: summ += 1 z -= y if z == 0: arry_prime_max.append((summ, x)) if z < 0: break v += 1 print('Result of the problem 50:', max(arry_prime_max)[0])