Blackthorn

17.ps1

Dec 23rd, 2022
1,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/usr/bin/env pwsh
  2.  
  3. param (
  4.     [string]$PuzzleInputFileName = "./2022/17.sample.input",
  5.     [string]$RockInputFileName = "./2022/17.rocks.input"
  6. )
  7.  
  8. $fallHeight = 3
  9. $worldWidth = 7
  10. $rocks = New-Object Collections.Generic.List[System.Tuple[int,int]]
  11. $world = New-Object Collections.Generic.Stack[String]
  12.  
  13. function Get-Rock() {
  14.     param (
  15.         [string] $rockString
  16.     )
  17.     $rock = New-Object 'Collections.Generic.List[System.Tuple[int,int]]'
  18.     $x = 0
  19.     $y = 0
  20.     for ($i = 0; $i -lt $rockString.Length; $i++) {
  21.         if ($rockString[$i] -eq "`n") {
  22.             $y++
  23.             $x = 0
  24.         } else {
  25.             $rock.Add(([System.Tuple]::Create( $x++, $y )))
  26.         }
  27.     }
  28.     [System.Tuple[int,int]] $returnValue
  29.     $returnValue = $rock.ToArray()
  30.     return $returnValue
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment