Sudal's Garage

Project Euler 15 본문

Programming/Project Euler - python

Project Euler 15

_Sudal 2019. 3. 3. 05:00

Question: 


Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.

How many such routes are there through a 20×20 grid?

문제:


2×2 격자가 있을 때, 왼쪽 상단 꼭지점으로부터 시작해서 오른쪽과 아래로만 움직여서 오른쪽 하단 꼭지점까지 가는 경로는 정확히 6개 존재한다.

그렇다면 20×20 격자에서는 몇 개의 경로가 존재할까?


Solution:


1
2
3
4
5
6
from sympy.functions.combinatorial.numbers import nC
= 20
a=list()
for i in range(N*2):
    a.append(i)
print(nC(a,N))
cs


오른쪽, 아래로 각각 20번씩 가는 경우의 수를 Combination 으로 구하면 된다.


2019/01/29 - [Programming/python] - Module: sympy






'Programming > Project Euler - python' 카테고리의 다른 글

Project Euler 17  (0) 2019.03.05
Project Euler 16  (0) 2019.03.04
Project Euler 14  (0) 2019.03.02
Project Euler 13  (0) 2019.02.28
Project Euler 12  (0) 2019.02.27