mirror of
https://github.com/paradizelost/AdventOfCode2020.git
synced 2024-11-25 02:44:45 -06:00
starting day 11
This commit is contained in:
parent
12742861c6
commit
e78c014af2
32
Advent Of Code Day 11-part1.ps1
Normal file
32
Advent Of Code Day 11-part1.ps1
Normal file
@ -0,0 +1,32 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user