aboutsummaryrefslogtreecommitdiff
path: root/challenge-227/lubos-kolouch/python/ch-1.py
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-07-31 15:49:22 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-07-31 15:49:22 +0800
commite7b6313261ef4541d4dcc303c46ef0d886649b70 (patch)
tree8cff819a2036dd8d0172b6343b0a199d7b81721a /challenge-227/lubos-kolouch/python/ch-1.py
parent4fda4a4a398e64921020704733556a2ec6dae78a (diff)
parente511966ce2280dbedb2c916d9e6254708800639e (diff)
downloadperlweeklychallenge-club-e7b6313261ef4541d4dcc303c46ef0d886649b70.tar.gz
perlweeklychallenge-club-e7b6313261ef4541d4dcc303c46ef0d886649b70.tar.bz2
perlweeklychallenge-club-e7b6313261ef4541d4dcc303c46ef0d886649b70.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-227/lubos-kolouch/python/ch-1.py')
-rw-r--r--challenge-227/lubos-kolouch/python/ch-1.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-227/lubos-kolouch/python/ch-1.py b/challenge-227/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..1a2e1d0042
--- /dev/null
+++ b/challenge-227/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from datetime import datetime, timedelta
+
+
+def friday_13ths(year):
+ dt = datetime(year, 1, 1)
+ friday_13_count = 0
+
+ while dt.year == year:
+ if dt.weekday() == 4 and dt.day == 13:
+ friday_13_count += 1
+ dt += timedelta(days=1)
+
+ return friday_13_count
+
+
+print(friday_13ths(2023)) # 2