A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
대칭수는 오른쪽에서 읽어도, 왼쪽에서 읽어도 똑같이 읽어진다. 두 자릿수의 곱으로 만들어진 가장 큰 대칭수는 9009 = 91 × 99 이다.
두 개의 세 자릿수로 만들어진 가장 큰 대칭수를 찾으시오.
# 생각 포인트
- 대칭수 확인 : if string = string[::-1]
100001, level 등을 확인하는 방법
# 풀이 : 906609
|
1
2
3
4
5
6
7
8
|
result = []
for i in range(900, 1000):
for j in range(900, 1000):
product = i * j
if str(product) == str(product)[::-1]:
result.append(product)
print(max(result))
|
cs |
그렇다면, 최종 결괏값을 구한 세 자릿수의 두 수는 무엇일까?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
i_total = []
j_total = []
result = []
for i in range(900, 1000):
for j in range(900, 1000):
product = i * j
if str(product) == str(product)[::-1]:
i_total.append(i)
j_total.append(j)
result.append(product)
print(i_total[-1])
print(j_total[-1])
print(max(result))
|
cs |
906609 = 993 × 913
'Python & SQL > Python Problems' 카테고리의 다른 글
| [파이썬 문제] 중복 문자열 다루기 (0) | 2021.04.26 |
|---|---|
| [프로젝트 오일러/파이썬] Smallest multiple (0) | 2021.04.18 |
| [프로젝트 오일러/파이썬] Largest prime factor (0) | 2021.04.18 |
| [프로젝트 오일러/파이썬] Even Fibonacci numbers (0) | 2021.04.18 |
| [프로젝트 오일러/파이썬] Multiples of 3 and 5 (0) | 2021.04.18 |