Skip to content

Instantly share code, notes, and snippets.

@JFFail
Created June 29, 2015 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFFail/1f49c0f5bc00edb6b423 to your computer and use it in GitHub Desktop.
Save JFFail/1f49c0f5bc00edb6b423 to your computer and use it in GitHub Desktop.
Solution to Reddit Daily Programmer #221 - Word Snake
#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