AdventOfCode2020/Advent Of Code Day 11-part1.ps1
2020-12-11 10:45:09 -06:00

32 lines
1.1 KiB
PowerShell

function Get-OpenSeatCount {
param (
[int]$seatrow,
[int]$seatnum
)
$seatrow.gettype()
$seatnum.gettype()
$seatrow = [int]$seatrow
$seatnum = [int]$seatnum
$seatrow.gettype()
$seatnum.gettype()
write-host "Input: $seatrow , $seatnum"
$positionstocheck=@{}
$positionstocheck.add('UpperLeft',@($seatrow -1,$seatnum -1))
$positionstocheck.add('UpperMiddle',@($seatrow -1,$seatnum))
$positionstocheck.add('UpperRight',@($seatrow -1,$seatnum +1))
$positionstocheck.add('Left',@($seatrow,$seatnum -1))
$positionstocheck.add('Right',@($seatrow,$seatnum +1))
$positionstocheck.add('LowerLeft',@($seatrow +1,$seatnum -1))
$positionstocheck.add('LowerMiddle',@($seatrow +1,$seatnum))
$positionstocheck.add('LowerRight',@($seatrow +1,$seatnum +1))
$occupiedSeats=0
foreach($position in $positionstocheck.keys){
$row,$num = $positionstocheck.$position
if($seatmap[$row][$num] -eq '#'){
$occupiedSeats++
}
}
return $occupiedSeats
}
$seatmap = get-content .\aocd11input.txt
Get-OpenSeatCount -seatrow 33 -seatnum 5