some progress

This commit is contained in:
dan 2020-12-11 12:02:06 -06:00
parent b8a95e2609
commit b0e0fbda58

View File

@ -4,13 +4,6 @@ function Get-OpenSeatCount {
[int]$seatnum,
$seatmap
)
$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)))
@ -23,28 +16,36 @@ function Get-OpenSeatCount {
$occupiedSeats=0
foreach($position in $positionstocheck.keys){
$row,$num = $positionstocheck.$position
if($seatmap[$row][$num] -eq '#'){
$myrow = $seatmap[$row]
if($myrow[$num] -eq '#'){
$occupiedSeats++
}
}
return $occupiedSeats
return [int]$occupiedSeats
}
function proc-Seats(){
param(
$seatmap
)
for($row=0;$row -lt $seatmap.count; $row++){
for($seatnum=0, $seatnum -lt $seatmap[$row].ToCharArray().count){
if((Get-OpenSeatCount -seatrow $row -seatnum $seatnum -seatmap $seatmap) -ge 4){
$seatmap[$row][$seatnum]='L'
} else {
$seatmap[$row][$seatnum]='#'
for($row=0;$row -lt $seatmap.count - 1; $row++){
for($seatnum=0; $seatnum -lt ($seatmap[$row].ToCharArray().count -1); $seatnum++){
if($seatmap[$row][$seatnum] -ne '.'){
$occupiedseats = Get-OpenSeatCount -seatrow $row -seatnum $seatnum -seatmap $seatmap
#write-host "Occupied Around $occupiedseats, SEATNUM $seatnum, SEATROW $row"
$myrow = $seatmap[$row].tochararray()
if( $occupiedseats -ge 4){
$myrow[$seatnum]='L'
$seatmap[$row]=$myrow -join ""
} else {
$myrow[$seatnum]='#'
$seatmap[$row]=$myrow -join ""
}
}
}
}
$seatmap
}
$seatmap = get-content .\aocd11input.txt
$seatmap = @(get-content .\aocd11input.txt)
$nochangesin=0
do{
$oldseatmap = $seatmap