aboutsummaryrefslogtreecommitdiff
path: root/challenge-137/lubos-kolouch/python/ch-1.py
blob: e8a1debe74fe8fd0d9d8b83f4c0e5c9b641a2720 (plain)
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
import datetime

def get_long_years():
    """ Get years with 53 weeks between 1900 and 2100 """

    result = []

    for year in range(1900,2101):
    
        my_date = datetime.date(year, 12, 31)

        if my_date.isocalendar().week == 53:
            result.append(year)

    return result


assert get_long_years() == [1903, 1908, 1914, 1920, 1925,
1931, 1936, 1942, 1948, 1953,
1959, 1964, 1970, 1976, 1981,
1987, 1992, 1998, 2004, 2009,
2015, 2020, 2026, 2032, 2037,
2043, 2048, 2054, 2060, 2065,
2071, 2076, 2082, 2088, 2093,
2099]