From 7460b6c29f4cd3e231b9440114d4e6e0e6908db0 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 9 Dec 2020 00:24:58 -0600 Subject: [PATCH] Functional day 9 part 2, just have to manually set the number looking for. next up is merging the 2 parts into 1. --- Advent Of Code Day 9-part2.ps1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Advent Of Code Day 9-part2.ps1 diff --git a/Advent Of Code Day 9-part2.ps1 b/Advent Of Code Day 9-part2.ps1 new file mode 100644 index 0000000..25b791e --- /dev/null +++ b/Advent Of Code Day 9-part2.ps1 @@ -0,0 +1,21 @@ +$inputdata=import-csv -header "Number" .\aocd9input.txt +$inputdata | %{$_.Number = [int64]$_.Number} +$howmanynums=2 + +foreach($num in ($howmanynums .. $inputdata.count)){ + + + for($i=0;$i -lt $inputdata.count - $num; $i++){ + $possiblevalues = @() + $mynums = $inputdata[$i .. ($i + $num -1)]|Select-Object -ExpandProperty Number + $mysum = $mynums | Measure-Object -sum | Select-Object -ExpandProperty Sum + if($mysum -eq 15353384){ + $minnum = ($mynums | Measure-Object -minimum).minimum + $maxnum = ($mynums | Measure-Object -Maximum).Maximum + write-host "$mynums sum to $mysum" + write-host "Smallest $minnum + Largest $maxnum = $($minnum + $maxnum)" + break + } + #write-host "$mynums : $mysum" + } +} \ No newline at end of file