Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Laminar
- 프로그래머스
- 파이썬
- 힙
- 프로젝트오일러
- 디스크 컨트롤러
- Fluids
- Crank-Nicolson
- 예제
- Navier-Stokes
- Statistics
- programmers
- 회귀
- 통계학
- Python
- Blasius
- Heat Equation
- Boundary Layers
- python3
- 이중우선순위큐
- 우선순위큐
- Turbulent
- regression
- projecteuler
- FTCS
- Fluid Dynamics
- 유체역학
- heap
- Compressible Flow
- Finite Difference Method
Archives
- Today
- Total
Sudal's Garage
Project Euler 19 본문
Question:
You are given the following information, but you may prefer to do some research for yourself.
- 1 Jan 1900 was a Monday.
- Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.- A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
문제:
다음은 달력에 관한 몇 가지 일반적인 정보입니다 (필요한 경우 좀 더 연구를 해 보셔도 좋습니다).
- 1900년 1월 1일은 월요일이다.
- 4월, 6월, 9월, 11월은 30일까지 있고, 1월, 3월, 5월, 7월, 8월, 10월, 12월은 31일까지 있다.
- 2월은 28일이지만, 윤년에는 29일까지 있다.
- 윤년은 연도를 4로 나누어 떨어지는 해를 말한다. 하지만 400으로 나누어 떨어지지 않는 매 100년째는 윤년이 아니며, 400으로 나누어 떨어지면 윤년이다
20세기 (1901년 1월 1일 ~ 2000년 12월 31일) 에서, 매월 1일이 일요일인 경우는 총 몇 번입니까?
Solution:
1 2 3 4 5 6 7 8 9 10 11 | import calendar,time sunday = 0 start = time.time() for year in range(1901,2001): for month in range(1,13): if calendar.weekday(year,month,1) == 6: # 6 = sunday sunday += 1 print("""The number of sundays on the first of the month: {} Found in ...{:.3f}s""".format(sunday,time.time()-start)) | cs |
calendar 모듈을 import 해서 써왔다.
2019/03/01 - [Programming/python] - Module: Calendar
1901년부터 2000년까지,
1일이 일요일일 때 카운트했다.
0.001 s 걸렸다!
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 21 (0) | 2019.03.09 |
---|---|
Project Euler 20 (0) | 2019.03.08 |
Project Euler 18 (0) | 2019.03.06 |
Project Euler 17 (0) | 2019.03.05 |
Project Euler 16 (0) | 2019.03.04 |