開源日報 每天推薦一個 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/