PoshCode Archive  Artifact [dfb47c2e02]

Artifact dfb47c2e02656aac8f98a1e0d95098619e6e63548cbb1d6232bb08d4e440108b:

  • File Infinite-Staircase.ps1 — part of check-in [8dea204392] at 2018-06-10 14:14:34 on branch trunk — Creates a stepped diagonal line going down to the right, then down to the left. (user: Nathan Estell size: 963)

# encoding: ascii
# api: powershell
# title: Infinite Staircase
# description: Creates a stepped diagonal line going down to the right, then down to the left.
# version: 0.1
# author: Nathan Estell
# license: CC0
# x-poshcode-id: 6380
# x-archived: 2016-10-06T10:50:49
# x-published: 2016-06-14T18:01:00
#
#
$spaces=0
for ([int]$rownum=1;;$rownum++) 
    {
    
    $StairDirection=[math]::floor($rownum/50)%2
    if ($StairDirection -eq 0)
        {
        for ($i=0; $i -lt $spaces; $i++) 
            {
            Write-Host " " -NoNewLine
            }
            $spaces++
        }
    if ($StairDirection -eq 1)
        {
            for ($j=0; $j -lt $spaces; $j++) 
                {
                Write-Host " " -NoNewLine
                }
           $spaces--
          if ($spaces -eq -1)
          {
          $spaces=1
          }
        }
        
    
    Write-Host " " -BackgroundColor "Green" 
}