Important: The deadline for this event has passed. Solutions are available in VBScript, Windows PowerShell, and Perl. |
In Image is Everything, competitors must write a script that displays a nicely-formatted calendar onscreen.
Not a native speaker of English? These event instructions are also available in the following languages: Chinese (Simplified); Chinese (Traditional); French; German; Japanese; Portuguese Brazilian; Russian; and Spanish. For more information, and to access these localized instructions, see the Scripting Games International page.
| About This Event | |
| Event Scenario |
Division | Advanced |
Deadline | Friday, February 22, 2008 (8:00 AM PST) |
Points Awarded | 5 |
To value external beauty without appreciating the inner beauty is the mark of a very shallow person. Welcome to toe world of the Scripting Guys!
Oh, and welcome to Event 4 in the Advanced Division.
Truth to be told, this is an easy one (relatively speaking, that is). To successfully complete this event you need to write a script that prompts a user to enter a month (using a numeric value: 1 for January, 2 for February, etc.) and a year (using a four-digit value like 2008). In other words, in response to your prompt we’ll enter a value like this to represent March, 2008:
3/2008
At that point all you have to do is generate and display (in the command window) a calendar for that month. For example, if the user enters a value of 2 (February) for the month and 2008 for the year, your script should display the following information in the command window:
February 2008
Sun Mon Tue Wed Thu Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29
The catch? You calendar must look similar to the one shown above including displaying the name of the month and the year, as well as the individual days of the week; in other words, it must look like a real calendar, just like you’d see in the Windows operating system:

In order to score this event, we will randomly pick – and enter – a month sometime between January, 2000 and December, 2010. And remember, neatness counts, at least to a very large extent. Your calendar doesn’t have to look exactly like the one we showed you; however, the calendar must be readable. Output similar to this will cause the script to fail:
February 2008
SMTWTFS
12
3456789
10111213141516
17181920212223
242526272829
Why will this fail? Because we can’t tell for sure which date has been assigned to a given day. For example, look at the third line of dates. Is the Sunday of that week the 1st, or the 10th? At the very least, give us output similar to this:
February 2008
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29
That’s not the coolest-looking calendar we’ve ever seen, but it will work.