The 2008 Winter Scripting Games

Advanced Event 9: You're Twisting My Words

Important: The deadline for this event has passed. Solutions are available in VBScript, Windows PowerShell, and Perl.

In You’re Twisting My Words, competitors must write a script that reverses the letters in each word in a text selection, all the while maintaining the same word order in that selection.

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.

*
On This Page
About This EventAbout This Event
Event ScenarioEvent Scenario
How to EnterHow to Enter

About This Event

Division

Advanced

Deadline

Monday, March 3, 2008 (8:00 AM PST)

Points Awarded

5

Top of pageTop of page

Event Scenario

Event 9 is probably the easiest of the Advanced Division events. However, it’s a tiny bit tricky, so make sure you read the instructions carefully.

You’re right; that was a silly thing to say, wasn’t it? After all, everyone always reads the instructions carefully, right?

To successfully complete this event your script must first read in the contents of the text file Alice.txt (which can be found in the Scripting Games Competitors’ Pack). After reading in the file, your script must then reverse the letters in each word in the file, all the while maintaining the order of those words. The script should then echo this revised string back to the screen.

What does it means to “reverse the letters in each word in the file, all the while maintaining the order of those words?” Well, suppose Alice.txt consists of the following:

This is my sentence.

Your script should read in the file, reverse the letters in each word, and then echo back the following:

sihT si ym .ecnetnes

See how that works? We reversed all the letters in the word This; however, the word This (or what’s left of it, anyway) is still the first word in the sentence. We then did the same thing for the words is, my, and sentence. Notice, too, that we’re counting punctuation marks as part of the word. That means that the following is a “word”, at least as far as Event 9 is concerned:

sentence.

In turn, that also means that this “word” should be reversed like so:

.ecnetnes

If you’re not 100% sure about this, practice by making the contents of Alice.txt equal to this:

This is my sentence.

As soon as your script can convert that to the following then you’re on your way:

sihT si ym .ecnetnes

Don’t worry about letter casing; that is, you don’t need to change the letter casing so that each sentence begins with an uppercase letter. Don’t bother doing this:

Siht si ym ecnetnes.

Just reverse the letters in each word, leaving the letter casing as-is. That’s good enough for this event.

Important notes. Make sure your script echoes the revised string back to the screen. Do not overwrite the contents of the file Alice.txt. If you do, you will not receive credit for successfully completing the event. Likewise, your script should use the path C:\Scripts\Alice.txt for the text file. If you do not use that path the odds are your script will fail.

Top of pageTop of page

How to Enter

After completing the script, click the appropriate link to submit your entry:

Advanced VBScript

Advanced Windows PowerShell

Advanced Perl

If the link doesn’t automatically open a pre-addressed message, send email to scripter@microsoft.com (in English, if possible) with the subject line Advanced VBScript: Event 9; Advanced Windows PowerShell: Event 9; or Advanced Perl: Event 9.

All you have to do is paste your code into the body of the message and then send the mail. You may also include the following:

A name or nickname we can use to identify you when posting Scripting Games points leaders.

The name of the country you would like to represent. This might be your country of birth or the country you currently live in, but it doesn’t have to be; you can represent any country you wish.

The name of any user group that you belong to. This should be included if your user group is participating in the User Group Challenge.

You can simply type these items in at the top of the email. In that case, your email (assuming you’re submitting an entry for the VBScript division) might look something like this:

Ken Myer
USA
Northern Iowa User Group

For i = 1 to 100
    Wscript.Echo i
Next

Top of pageTop of page