Why not a post devoted to a day?
Today is February 29. Leap Day.
There’s lots to think about on this day. Foremost, it means that there’s an extra day in 2016. That means that March Break comes a day later than normal. With the ups and downs of the weather, going south for good weather might be a crap shoot. There just might be great weather here. Spring training is always on television.
Time and years are an interesting concept. We’ve made it simple in the computer age but it’s long been mankind’s desire to completely understand and quantify it. We have time zones, for example, to level the playing field although this interesting article outlines a plan to do away with them. Even around here, there are things that aren’t digital and need to be adjusted manually so we’re not quite there yet. I do live in a time zone (ET) that does adjust clocks but there are some areas that don’t. It hasn’t gone missing by Microsoft which, as a technology company, wants to do it right. Here’s an interesting bulletin to read.
And you know that they, and all computer manufacturers, want to get it right. All you ever want to know about Leap Day can be found here.
Or in the computer science classroom.
A favourite programming assignment that shows how to build in scaffolding into coding was a Grade 11 problem in my class.
We’d start small.
Problem: Enter two dates in the same month, in order (first, second), and calculate the number of days between them.
Now, there were a number of different ways to write the code for that and it was always fun and actually proved to be a nice start.
Problem 2: Enter two dates in the same month, in any order, and calculate the number of days between them.
That’s a little more challenging because you never know which date would be entered first so you have to develop a solution to properly do the calculation. Of course, there is more than one way to solve this one too.
Problem 3: Enter two dates in the year, in any order, and calculate the number of days between them.
You know, this would be a whole lot easier if every month had the same number of days. We review the number of days in a month by counting on our knuckles! You use whatever tools are handy.
Problem 4: Enter two dates that might be in this year and next year, in any order, and calculate the number of days between them.
Now it gets a bit tedious and the questions start. Siiiiir, when would we ever need to do this other than in your class? A quick discussion about banks and daily interest or determining the number of days until the next holiday heads that off.
Problem 5: Enter two dates in the past century, in any order, and calculate the number of days between them.
Finally, sir. An easy one. I just need to add a few statements to the last version and we’re done.
Until we discuss leap years.
Of course everyone knows about them; they just never had to write the code for it. So, we discuss how to determine whether or not a year is a Leap Year, and it’s the sort of thing that makes for a great discussion and algorithm design. It’s also a practical example of talking about exceptions when you’re coding and how you need to keep your eyes and mind open to check for data that might be a little different from what is expected. It’s not just about being tricked into dividing by zero.
Thank you, Caesar.
Nowadays, it’s a one-liner on your favourite online spreadsheet.