This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
And up for the answer to Event 6 but then in MSH
Event 6 is the
Word Search Slalom ,
I liked this one, thas solves a Word Square.
I did skip event 6 for here as it's excel and not much different,
I will do the 15 points option, finding the words horizontal and vertical in the wordsquare.
The script looks like this :
$words = ("ADSI","CONNECT","CREATE","CSCRIPT","EACH","ERROR","LOOP","METHOD","OBJECT","SCRIPTING","SUB","THEN","WINMGMTS")
# Get Text
$text = gc C:\scripts\event_6b.txt
# reverse the text
$textR = $text | foreach {$a = $_.ToCharArray();[array]::reverse($a);[string]::join("",$a)}
# Get Vertical Text
$textV = [string]::join("",(0..($text[0].length - 1) | foreach {$i=$_;$text | foreach {$_[$i]}}))
# reverse the vertical text
$VR = $V | foreach {$a = $_.ToCharArray();[array]::reverse($a);[string]::join("",$a)}
# find the words
$found = @()
$words | foreach {if ($VR -match $_){$found += $_}}
$words | foreach {if ($text -match $_){$found += $_}}
$words | foreach {if ($textR -match $_){$found += $_}}
$words | foreach {if ($textV -match $_){$found += $_}}
# output results
$words | foreach {"$_ = $($found -contains $_)"}
*EDIT*after a comment from DontBotherMeWithSpam (thanks),
I came up with this replacement for the Find words section :# find the words
foreach ($word in $words){$Text,$textR,$textV,$vr | foreach {if($_ -match $word){$found += $word}}}
*EDIT2*Fixed a naming typo in the origional script and the textV line is cleaned up.
$found = @()
$words = ("ADSI","CONNECT","CREATE","CSCRIPT","EACH","ERROR","LOOP","METHOD","OBJECT","SCRIPTING","SUB","THEN","WINMGMTS")
# Arrange text
$text = gc C:\scripts\event_6b.txt
$textR = $text | foreach {$a = $_.ToCharArray();[array]::reverse($a);[string]::join("",$a)}
$textV = [string]::join("",(0..($text[0].length - 1) | foreach {Foreach ($line in $text){$Line[$_]}}))
$textVR = $textV | foreach {$a = $_.ToCharArray();[array]::reverse($a);[string]::join("",$a)}
# find the words
foreach ($word in $words){$Text,$textR,$textV,$textVR | foreach {if($_ -match $word){$found += $word}}}
# output results
$words | foreach {"$_ = $($found -contains $_)"}
enjoy,
Greetings /\/\o\/\/
Tags : Monad mshPS In 2 day's with Event 7's solution I will post I nice replacement for the last line.