반응형
2배, 3배, 4배, 5배, 6배의 결과도 같은 숫자로 이루어지는 가장 작은 수
Problem 52
125874를 2배 하면 251748이 되는데, 이 둘은 같은 숫자로 이루어져 있고 순서만 다릅니다.
2배, 3배, 4배, 5배, 6배의 결과도 같은 숫자로 이루어지는 가장 작은 수는 무엇입니까?
from itertools import permutations
def isPermutation(i,j):
permutation_j = set("".join(x) for x in permutations(str(j),len(str(i))))
if str(i) not in permutation_j:
return False
return True
i = 1
result = []
while True:
nums_1 = 1 * i
nums_2 = 2 * i
nums_3 = 3 * i
nums_4 = 4 * i
nums_5 = 5 * i
nums_6 = 6 * i
if isPermutation(i, nums_1) and isPermutation(i, nums_2) and isPermutation(i, nums_3) and \
isPermutation(i, nums_4) and isPermutation(i, nums_5) and isPermutation(i, nums_6):
result.append(i)
break
i+=1
print(result)
Problem 53
1 ≤ n ≤ 100 일때 nCr의 값이 1백만을 넘는 경우는 모두 몇 번?
def factorial(n):
if n == 0 or n ==1:
return n
else:
return n * factorial(n-1)
from tqdm.notebook import tqdm
cnt = 0
for n in tqdm(range(1,101)):
for r in range(1, n):
result = factorial(n) / (factorial(r)*factorial(n-r))
if result >1000000:
cnt +=1
print(cnt)
Problem 54
포커 게임에서 이긴 횟수 구하기
반응형
'문제 > Project Euler(프로젝트 오일러)' 카테고리의 다른 글
Problem 42 ~ 51 (0) | 2021.05.20 |
---|---|
Problem 32 ~ 41 (0) | 2021.02.26 |
Problem 22~ Problem 31 (0) | 2021.02.03 |
Problem 12 ~ Problem 21 (0) | 2021.01.19 |
Problem 1~Problem 11 (0) | 2020.08.21 |