diff options
| -rw-r--r-- | challenge-137/lubos-kolouch/python/ch-1.py | 25 | ||||
| -rw-r--r-- | challenge-137/lubos-kolouch/python/ch-2.py | 22 |
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-137/lubos-kolouch/python/ch-1.py b/challenge-137/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..e8a1debe74 --- /dev/null +++ b/challenge-137/lubos-kolouch/python/ch-1.py @@ -0,0 +1,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] diff --git a/challenge-137/lubos-kolouch/python/ch-2.py b/challenge-137/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..ccc74c8ac8 --- /dev/null +++ b/challenge-137/lubos-kolouch/python/ch-2.py @@ -0,0 +1,22 @@ +def is_lychrel_number(what: int): + + """ Check if the number is Lychrel """ + iter_count = 0 + + while iter_count < 500: + iter_count += 1 + + what += int(str(what)[::-1]) + + if what >= 10_000_000: + break + + if what == int(str(what)[::-1]): + return 0 + return 1 + + +assert is_lychrel_number(56) == 0 +assert is_lychrel_number(57) == 0 +assert is_lychrel_number(59) == 0 +assert is_lychrel_number(10911) == 1 |
