Computing, Education, and Computing Education
RSS

Calendar problem revisited

January 3rd, 2008   Posted by John in assignments, cs1 | Comments Off calendarHere’s a twist on the classic “What day of the week does a particular date fall on?” problem. A programming solution using the following approach would use several simple lookup tables, probably implemented as arrays, lists, or hash maps. I’ve translated the basic idea that I found here (via reddit) into something more appropriate for programming instructors and students.The result can be calculated using the following formula:dayOfWeek = (yearCode + monthCode + day) % 7The result is an integer in the range 0 to 6, interpreted as follows:
ResultDay
0Saturday
1Sunday
2Monday
3Tuesday
4Wednesday
5Thursday
6Friday
As usual, leap year needs to be accounted for. If the date in question is in a leap year, the result should be decremented by one for the months of January and February.The month code is a non-intuitive integer as follows:
MonthCode
January1
February4
March4
April0
May2
June5
July0
August3
September6
October1
November4
December6
The year code can also be determined using a lookup table, such as:
YearCode
20055
20066
20070
20082
20093
20104
Or the year code can be computed using the following formula:yearCode = (centuryCode + twoDigitYear + (twoDigitYear / 4)) % 7The two digit year value is the last two digits of the year (84 for 1984). The century code follows the 6-4-2-0 pattern below and applies only to dates in theGregorian calendar.
CenturyCode
1600s6
1700s4
1800s2
1900s0
2000s6
2100s4
2200s2
2300s0
Happy programming.

What’s in a name?

January 2nd, 2008   Posted by John in website | Comments Off white roseOne of the best things about a life in academia is that it begins fresh every few months.Each semester there are new courses, new students, and new pedagogical challenges. And whenyour focus is computing, your topic is a moving target. So while we are guided by certain coreprinciples, we must also continually evolve our knowledge and the strategies for communicatingthat knowledge to students. I suspect that all computing educators worthy of the name make changesto their courses almost every time they are offered. Thus the nameNew Syllabus.That, and I was trying to find a decent URL and something that would pass a corporate namesearch.I think I’ll add a version of this post to the new About page (stickingwith the pedagogical slant).

Welcome

January 1st, 2008   Posted by John in website | Comments Off sun burstI’m finally getting around to creating a permanent web presence after moving to Virginia.I had glorious plans to get it set up right away, of course, which quickly fell apart as I gotswamped with a new house, new schools (I teach at two now!), and getting the family settled.More on the transition, and the reasons for it, later. Plus there have been some big projectsin the works. Somehow after giving up my “real job” I’m busier than I’ve ever been.I’ll use this site to post information about textbook revisions and supplements, and as avehicle for fleshing out ideas for new projects. I’ll also use it to manage course materials,though I’ll probably rely more on the web resources at the appropriate school for detailed courseinformation.Questions and comments are always welcome.