Monday, March 03, 2008

2008 Scripting Games, Solution 9

# Advanced Event 9: You're Twisting My Words
# http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent9.mspx

# Load text from file
$text=type c:\scripts\alice.txt
# Split into words (space delimited)
# Convert each word to a character array, reverse the array and construct a string again
$all=$text.split(" ") | % { $w=$_.tochararray(); [array]::reverse($w); [string]::join("",$w) }
# Finally, convert all words a line of text using the default $OFS delimiter (which is space)
"$all"

No comments: