If you aren't already in the know, these ten problems are from the 2008 Winter Scripting games.

For each problem, I'm going to quickly sum up the interesting (interesting TO ME) bits of each problem, then I'm going to post the full source.

Event 9: You're Twisting My Words

Simple: reverse letters in each word, WITHOUT reversing the order of the words. It's a simple case of breaking down the huge string into tokens, then reversing the contents of the tokens, then re-combining the tokens. Actually it's even simpler than I described. Moving on.


function Reverse-LettersInWord ($word)
    $reversedChars = @()
    for ($i = $word.Length - 1; $i -ge 0; $i--)
        $reversedChars += $word[$i]
    [string]::Join("", $reversedChars)

function Solve-Problem9
    [string]::Join(" ", ( ( (cat "C:\Scripts\alice.txt").Split(" ") ) | % { Reverse-LettersInWord -word $_ } ) )


2008 Winter Scripting Game Events: Index