mirror of
https://github.com/paradizelost/AdventOfCode2020.git
synced 2024-11-25 02:44:45 -06:00
some progress
This commit is contained in:
parent
b8a95e2609
commit
b0e0fbda58
@ -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'
|
||||
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 {
|
||||
$seatmap[$row][$seatnum]='#'
|
||||
$myrow[$seatnum]='#'
|
||||
$seatmap[$row]=$myrow -join ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$seatmap
|
||||
}
|
||||
$seatmap = get-content .\aocd11input.txt
|
||||
$seatmap = @(get-content .\aocd11input.txt)
|
||||
$nochangesin=0
|
||||
do{
|
||||
$oldseatmap = $seatmap
|
||||
|
Loading…
Reference in New Issue
Block a user