Created
June 29, 2015 19:52
-
-
Save JFFail/1f49c0f5bc00edb6b423 to your computer and use it in GitHub Desktop.
Solution to Reddit Daily Programmer #221 - Word Snake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://www.reddit.com/r/dailyprogrammer/comments/3bi5na/20150629_challenge_221_easy_word_snake/ | |
$words = "SHENANIGANS SALTY YOUNGSTER ROUND DOUBLET TERABYTE ESSENCE" | |
$wordArray = $words.Split(" ") | |
$counter = 0 | |
$space = "" | |
foreach($word in $wordArray) | |
{ | |
if($counter % 2 -eq 0) | |
{ | |
Write-Host $space -NoNewline | |
Write-Host $word | |
$space += (" " * ($word.Length - 1)) | |
} | |
else | |
{ | |
$charArray = $word.ToCharArray() | |
foreach($letter in $charArray) | |
{ | |
Write-Host $space -NoNewline | |
Write-Host $letter | |
} | |
} | |
$counter++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment