一则新闻引发的思考(20200202千年一遇对称日 厦门可正常办结婚登记)
第一直觉,有点不信,为啥是千年一遇的对称日,废话不多说,代码来验证!
1
2
3
4
5
6
7
8
9
10
11
12
13
month_day = {'01': 31, '02': 28, '03':31, '04':30, '05':31, '06':30, '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}
all_m_d = []
for mon, days in month_day.items():
for day in range(1, days+1):
temp = str(mon) + '{:0>2}'.format(str(day))
all_m_d.append(temp)
for i in range(1949, 3000):
year = str(i)
if year[::-1] in all_m_d:
print(year+year[::-1])
结果如下:
View Code
观察后发现,千年对称日??明年就有好吧(20211202)!
再猜测:是不是 两个数字组成的对称日,千年才有一次?
验证如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
month_day = {'01': 31, '02': 28, '03':31, '04':30, '05':31, '06':30, '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}
all_m_d = []
for mon, days in month_day.items():
for day in range(1, days+1):
temp = str(mon) + '{:0>2}'.format(str(day))
all_m_d.append(temp)
for i in range(1949, 5000):
year = str(i)
if year[::-1] in all_m_d:
y_m_d = year+year[::-1]
if len(set(y_m_d)) == 2:
print(y_m_d)
结果如下:
20200202
21111112
21211212
22111122
22200222
22211222
30300303
31111113
40400404
41111114
2111 - 2020 = 91
也不是!!这才隔了91年!
总结:
面对媒体的言论,要保持理智清醒的头脑!
谢谢看官,溜了溜了
Only action can relieve the uneasiness.https://www.cnblogs.com/liangmingshen/p/12178189.html