일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 우선순위큐
- Finite Difference Method
- Blasius
- 파이썬
- 예제
- Heat Equation
- regression
- 유체역학
- Fluid Dynamics
- 통계학
- heap
- 디스크 컨트롤러
- Laminar
- projecteuler
- Statistics
- Crank-Nicolson
- 이중우선순위큐
- 프로그래머스
- Boundary Layers
- Compressible Flow
- Python
- 프로젝트오일러
- 힙
- Fluids
- Navier-Stokes
- Turbulent
- python3
- programmers
- FTCS
- 회귀
- Today
- Total
Sudal's Garage
Project Euler 24 본문
Question:
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
012 021 102 120 201 210
What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
문제:
어떤 대상을 순서에 따라 배열한 것을 순열이라고 합니다. 예를 들어 3124는 숫자 1, 2, 3, 4로 만들 수 있는 순열 중 하나입니다.
이렇게 만들 수 있는 모든 순열을 숫자나 문자 순으로 늘어놓은 것을 사전식(lexicographic) 순서라고 합니다.
0, 1, 2로 만들 수 있는 사전식 순열은 다음과 같습니다.012 021 102 120 201 210
0, 1, 2, 3, 4, 5, 6, 7, 8, 9로 만들 수 있는 사전식 순열에서 1,000,000번째는 무엇입니까?
Solution:
from itertools import permutations import time start= time.time() a =[0,1,2,3,4,5,6,7,8,9] print("".join(list(map(str,list(permutations(a))[1000000 - 1])))) print("Found in ...{:.3f}s".format(time.time() - start))
순열을 반환하는 함수 permutation 을 itertools 에서 가져왔다.
2019/03/01 - [Programming/python] - Module: itertools
1.016s 걸렸다
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 27 (0) | 2019.03.15 |
---|---|
Project Euler 25 (0) | 2019.03.13 |
Project Euler 23 (0) | 2019.03.11 |
Project Euler 22 (0) | 2019.03.10 |
Project Euler 21 (0) | 2019.03.09 |