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,
|
[int]$seatnum,
|
||||||
$seatmap
|
$seatmap
|
||||||
)
|
)
|
||||||
$seatrow.gettype()
|
|
||||||
$seatnum.gettype()
|
|
||||||
$seatrow = [int]$seatrow
|
|
||||||
$seatnum = [int]$seatnum
|
|
||||||
$seatrow.gettype()
|
|
||||||
$seatnum.gettype()
|
|
||||||
write-host "Input: $seatrow , $seatnum"
|
|
||||||
$positionstocheck=@{}
|
$positionstocheck=@{}
|
||||||
$positionstocheck.add('UpperLeft',@(($seatrow -1),($seatnum -1)))
|
$positionstocheck.add('UpperLeft',@(($seatrow -1),($seatnum -1)))
|
||||||
$positionstocheck.add('UpperMiddle',@(($seatrow -1),($seatnum)))
|
$positionstocheck.add('UpperMiddle',@(($seatrow -1),($seatnum)))
|
||||||
@ -23,28 +16,36 @@ function Get-OpenSeatCount {
|
|||||||
$occupiedSeats=0
|
$occupiedSeats=0
|
||||||
foreach($position in $positionstocheck.keys){
|
foreach($position in $positionstocheck.keys){
|
||||||
$row,$num = $positionstocheck.$position
|
$row,$num = $positionstocheck.$position
|
||||||
if($seatmap[$row][$num] -eq '#'){
|
$myrow = $seatmap[$row]
|
||||||
|
if($myrow[$num] -eq '#'){
|
||||||
$occupiedSeats++
|
$occupiedSeats++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $occupiedSeats
|
return [int]$occupiedSeats
|
||||||
}
|
}
|
||||||
function proc-Seats(){
|
function proc-Seats(){
|
||||||
param(
|
param(
|
||||||
$seatmap
|
$seatmap
|
||||||
)
|
)
|
||||||
for($row=0;$row -lt $seatmap.count; $row++){
|
for($row=0;$row -lt $seatmap.count - 1; $row++){
|
||||||
for($seatnum=0, $seatnum -lt $seatmap[$row].ToCharArray().count){
|
for($seatnum=0; $seatnum -lt ($seatmap[$row].ToCharArray().count -1); $seatnum++){
|
||||||
if((Get-OpenSeatCount -seatrow $row -seatnum $seatnum -seatmap $seatmap) -ge 4){
|
if($seatmap[$row][$seatnum] -ne '.'){
|
||||||
$seatmap[$row][$seatnum]='L'
|
$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 {
|
} else {
|
||||||
$seatmap[$row][$seatnum]='#'
|
$myrow[$seatnum]='#'
|
||||||
|
$seatmap[$row]=$myrow -join ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$seatmap
|
$seatmap
|
||||||
}
|
}
|
||||||
$seatmap = get-content .\aocd11input.txt
|
$seatmap = @(get-content .\aocd11input.txt)
|
||||||
$nochangesin=0
|
$nochangesin=0
|
||||||
do{
|
do{
|
||||||
$oldseatmap = $seatmap
|
$oldseatmap = $seatmap
|
||||||
|
Loading…
Reference in New Issue
Block a user