Skip to content

Instantly share code, notes, and snippets.

@JFFail
Last active August 29, 2015 14:14
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/75b2dd43fa3a030457d4 to your computer and use it in GitHub Desktop.
Save JFFail/75b2dd43fa3a030457d4 to your computer and use it in GitHub Desktop.
Solution To Reddit Daily Programmer 199 - Bank Number Banners
<#
# Challenge is here:
# http://www.reddit.com/r/dailyprogrammer/comments/2tr6yn/2015126_challenge_199_bank_number_banners_pt_1/
#>
#Function to loop through each of the supplied inputs.
function ParseNums
{
param([string] $passedNum)
#Create arrays to define each letter.
$charsLevel1 = " _ ", " ", " _ ", " _ ", " ", " _ ", " _ ", " _ ", " _ ", " _ "
$charsLevel2 = "| |", " |", " _|", " _|", "|_|", "|_ ", "|_ ", " |", "|_|", "|_|"
$charsLevel3 = "|_|", " |", "|_ ", " _|", " |", " _|", "|_|", " |", "|_|", " _|"
#Create new arrays to hold the results at each level.
$resultLevel1 = @()
$resultLevel2 = @()
$resultLevel3 = @()
#Turn the string with the base number into an array of integers.
$numArray = [int[]][string[]][char[]]$passedNum
#Loop through the array.
foreach($number in $numArray)
{
$resultLevel1 += $charsLevel1[$number]
$resultLevel2 += $charsLevel2[$number]
$resultLevel3 += $charsLevel3[$number]
#Add a space after each.
$resultLevel1 += " "
$resultLevel2 += " "
$resultLevel3 += " "
}
#Now print the results.
foreach($entry in $resultLevel1)
{
Write-Host $entry -NoNewline
}
Write-Host ""
foreach($entry in $resultLevel2)
{
Write-Host $entry -NoNewline
}
Write-Host ""
foreach($entry in $resultLevel3)
{
Write-Host $entry -NoNewline
}
Write-Host "`n"
}
#Get the inputs.
$firstNum = "000000000"
$secondNum = "111111111"
$thirdNum = "490067715"
#Call the function.
ParseNums -passedNum $firstNum
ParseNums -passedNum $secondNum
ParseNums -passedNum $thirdNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment