根据这段视频的数据,太阳年是365天、5小时、48分钟、45秒和138毫秒。在目前的公历中,闰年的规则如下:
if year is divisible by 400, LEAP YEAR
else if year is divisible by 100, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
else, COMMON YEAR
不幸的是,这种方法每隔3216年就会停止一天。
改革日历的一个可能方法是下列规则:
if year is divisible by 128, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
else, COMMON YEAR
这样做的好处是不需要我们在另一个62.5万年内改变我们的日历,无论是给予还是接受。
假设全世界都认为,从现在开始,除了每128年以外,我们每四年都使用这个系统,改变我们的日历如下:
YEAR GREGORIAN 128-YEAR
2044 LEAP LEAP
2048 LEAP COMMON
2052 LEAP LEAP
...
2096 LEAP LEAP
2100 COMMON LEAP
2104 LEAP LEAP
...
2296 LEAP LEAP
2300 COMMON LEAP
2304 LEAP COMMON
2308 LEAP LEAP
这将如何影响我们的一周一天的算法?
挑战
"28 February 2048" -> "Friday"
"March 1, 2048" -> "Sat"
(2100, 2, 29) -> 0 # 0-indexed with Sunday as 0
"2100-02-29" -> 7 # 1-indexed with Sunday as 7
"28 Feb. 2176" -> "Wednesday"
"1-Mar-2176" -> "Th"
"28/02/100000" -> "F" # DD/MM/YYYYYY
"Feb. 29, 100000" -> 6 # 1-indexed with Sunday as 7
"03/01/100000" -> 1 # MM/DD/YYYYYY and 1-indexed with Sunday as 1
欢迎就这项挑战提出建议和反馈意见。祝你好运,打高尔夫球!
发布于 2017-11-30 22:59:46
发布于 2017-12-01 07:02:17
发布于 2017-12-01 16:13:36
这是诺贾根修正 of Sakamoto算法的一个端口,但是有一些基于堆栈的技巧,如下所述。输入格式为day, year, month
。输出格式为0-indexed with Sunday as 0
。欢迎您打高尔夫球!在网上试试!!
;"0032503514624"Ei)3>±+;¼L;¼¼½L±kΣ7@%
Implicit input: day, year, month (month is at TOS)
;"0032503514624"Ei) Get the month code, convert to float, rotate to bottom of the stack
3>±+ If 3>month, add -1 to year
;¼L Push floor(year/4) to stack
;¼¼½L± Push floor(year/4) and append -floor(year/128) to stack.
kΣ Wrap the stack (y/128, y/4, y, month_code, d) in a list and sum
7@% Get the sum modulo 7
Implicit return
https://codegolf.stackexchange.com/questions/149573
复制相似问题