mirror of
https://github.com/paradizelost/AdventOfCode2020.git
synced 2024-11-24 18:34:45 -06:00
39 lines
1.1 KiB
PowerShell
39 lines
1.1 KiB
PowerShell
$input=get-content "aocd6input.txt" -Raw
|
|
|
|
$mydata = $input -split "(\r?\n){2}"
|
|
$mysum=0
|
|
foreach($form in $mydata){
|
|
$group=$form.split("`n")
|
|
$mygroup=@{}
|
|
if($form -eq "`n"){
|
|
continue
|
|
}
|
|
$emptycount = 0
|
|
foreach($person in $group){
|
|
if($person.length -eq 0){
|
|
$emptycount++
|
|
continue
|
|
} else {
|
|
foreach($char in $person.ToCharArray()){
|
|
if(-not($mygroup[$char])){
|
|
$mygroup[$char]=1
|
|
} else {
|
|
$mygroup[$char]= $mygroup[$char]+1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$mytotal = $mygroup.keys|ForEach-Object {$mygroup[$_]|where-object {[int]$_ -eq ([int]$group.count - [int]$emptycount)}}
|
|
$mysum+=$mytotal.count
|
|
write-host @"
|
|
Count of group: $($group.count)
|
|
Empty Count: $($emptycount)
|
|
Tallys: $($mygroup.keys|ForEach-Object {$mygroup[$_]})
|
|
MyTotal: $mytotal
|
|
MySum: $mysum
|
|
MyCount: $($mytotal.count)
|
|
Group Answers: $group
|
|
"@
|
|
}
|
|
write-host "FINAL: $mysum" |