开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
今日推荐开源项目:《罗伯特 robocode》
今日推荐英文原文:《How to Perform Calendar Calculations in Your Head》
开源日报第580期:《罗伯特 robocode》
今日推荐开源项目:《罗伯特 robocode》传送门:GitHub链接
推荐理由:程序员之间对上眼的时候就要来一场战斗——当然了,并没有人这么说过。不过如果你真的想要用代码来战斗,这个项目兴许能够满足你。你可以在这个项目里创造一架跑着自己写的代码的机器人,通过调用各种函数来进行各种操作最后射爆场上的所有人。说着很简单,但是如果融入自己所学的各种算法等等之后,每个人的机器人都会大不相同,团建什么的时候自然可以拿这个来让大家互相打一架。
今日推荐英文原文:《How to Perform Calendar Calculations in Your Head》作者:Jørgen Veisdal
原文链接:https://medium.com/cantors-paradise/how-to-perform-calendar-calculations-5617f35d3070
推荐理由:算出某一天是星期几的算式,虽然可能比较慢……

How to Perform Calendar Calculations in Your Head

A so-called calendrical savant (or calendar savant) is someone who despite their intellectual disability (typically autism) can name the day of the week of a given date, or visa versa in a few seconds or even a tenth of a second (Kennedy & Squire, 2007).While extremely impressive to behold, calendar calculations are actually very simple to perform and can be learned in less than 30 minutes. This short article will teach you how.

What day was the 13th of January 1989?

My birthday. I was born two weeks late. Here is how to calculate which day of the week that was (Lancaster, 2005):

Step 1. Calculate the Year Code Y

The first step of our five step process is to calculate the year code, represented by the letter Y. This is done in the following way: So, for the date 13th of January 1989 we obtain the year code Y =111.

Step 2. Find the Month Code M

The second step of our five step calculation is to find the month code M. This is a simple step, simply look it up in the table below (or better, memorize it): As we know, leap years occur every four years (even years). Century years like 1900, 2000 and 2100 are leap years if they are evenly divisible by 400.

For the date 13th of January 1989, we obtain the month code M = 1.

Step 3. Find the Day Code D

The third step of our five step calculation is to find the day code D. This iS even easier than finding the month code, as it is simply the number of the date itself. For the 13th of January 1989, the number is D = 13.

Step 4. Find the sum of the numbers Y + M + D

The fourth step of our five step model is to add the three numbers we’ve found. For our three numbers, the sum is 111 + 1 + 13 = 125.

Step 5. Find the Day of the week

The final step of the calculation is to calculate the remainder of the modulo operation 125 mod 7. We know that 7 x 17 is 119, leaving a remainder of 6: The 13th of January 1989 was a Friday. Yes, I was born on Friday the 13th.
下载开源日报APP:https://openingsource.org/2579/
加入我们:https://openingsource.org/about/join/
关注我们:https://openingsource.org/about/love/