목록Algorithm/ProjectEuler (18)
Try
Field = [ ['75'], ['95', '64'], ['17', '47', '82'], ['18', '35', '87', '10'], ['20', '04', '82', '47', '65'], ['19', '01', '23', '75', '03', '34'], ['88', '02', '77', '73', '07', '63', '67'], ['99', '65', '04', '28', '06', '16', '70', '92'], ['41', '41', '26', '56', '83', '40', '80', '70', '33'], ['41', '48', '72', '33', '47', '32', '37', '16', '94', '29'], ['53', '71', '44', '65', '25', '43', '..
numbers = { 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety', 100: 'hundred', 1000: 'thou..
num = 1 for i in range(1000): num *= 2 res = 0 while 1: if num < 10: res += num break res += num % 10 num = num // 10 print(res) 출처 http://euler.synap.co.kr/prob_detail.php?id=16
dp = [[0] * 21 for _ in range (21)] for i in range(21): dp[i][0] = 1 dp[0][i] = 1 for i in range(1, 21): for j in range(1, 21): dp[i][j] = dp[i-1][j] + dp[i][j-1] print(dp[20][20]) 출처 http://euler.synap.co.kr/prob_detail.php?id=15
MAX = 0 cntMAX = 0 for i in range(1, 1000000): cnt = 0 temp = i N = i while 1: if N == 1: if cnt > cntMAX: MAX = temp cntMAX = cnt break if N % 2 == 0: N = N // 2 cnt += 1 else: N = 3 * N + 1 cnt += 1 print(MAX, cntMAX) 출처 http://euler.synap.co.kr/prob_detail.php?id=14
data='''37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 89261670696623633820136378418383684178734361726757 28112879812849979408065481931592621691275889832738 442742289174325203219235894228767..
import time start_time = time.time() def count_factors(num): loop=num**0.5 # for square number if loop==int(loop): count=1 else: count=0 i=1 while i 500: break i+=1 print("answer:",tri_num) print("calculation time:",time.time()-start_time) #출처 https://www.opentutorials.org/module/2980/17520 출처 http://euler.synap.co.kr/prob_detail.php?id=12
data='''08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 32 98 81 28 64 23 67 10 26 38 ..
CHECK = [False, False] + [True] * 2000000 SUM = 0 for i in range(2, 2000000): if CHECK[i]: SUM += i for j in range(2 * i, 2000000, i): CHECK[j] = False print(SUM) 출처 http://euler.synap.co.kr/submit_answer.php
def solution(): for i in range(1000): for j in range(1000): for k in range(1000): if i == 0 or j == 0 or k == 0: continue if i + j + k == 1000: if i*i + j*j == k*k: print(i * j * k) return solution() 출처 http://euler.synap.co.kr/prob_detail.php?id=9