Sunday, September 15, 2013

Algorithm Summary

In the second day of class we were assigned the task of creating an algorithm that determines the day of the week for a set date. My partner jplafor ( http://programmingwithjplafor.blogspot.com ), started brainstorming ideas, and after about 10 minutes I managed to pull an equation out of thin air that actually worked for what we were doing. That equation is D - (7W). Where D is equal to Days from the first of March 2001, and W is equal to the amount of weeks from that day, rounded down to the whole number. D is determined by the equation (([Year]-2001)365)+M+A+L. In this equation M is equal to the amount of days for each month, ie input 10 = 213 because at the start of October 213 days have already happened since the first of march. A = the date selected, ie the 5th =A=5. And L is the leap year equation, where you divide ([Year]-2000) by 4, and round down in order to find the amount of leap year days to add to the equation for the day. Once all the variables are determined, and the equation is done out, you then have D. To determine W, you divide D by 7, and round down to the whole number. Do that equation out and you will have a number between 1 and 7. 1=Thursday, 2=Friday, and so on. I spent a few hours putting this into a scratch program, but I am still troubleshooting it. But it is nearly working.
EDIT: This should work perfectly fine now, but make sure to select the year first, and then press b before continuing date
Controls: Q and A: Up and Down for Day of the month
W and S: Up and Down for Month
E and D: Up and down for Year

No comments:

Post a Comment