From 12742861c632f50d38a77049cb77b0a0cbbe8cb4 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 9 Dec 2020 23:25:53 -0600 Subject: [PATCH] Day 10 part 1 done --- Advent Of Code Day 10-part1.ps1 | 18 ++++++ aocd10input.txt | 108 ++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 Advent Of Code Day 10-part1.ps1 create mode 100644 aocd10input.txt diff --git a/Advent Of Code Day 10-part1.ps1 b/Advent Of Code Day 10-part1.ps1 new file mode 100644 index 0000000..31125d0 --- /dev/null +++ b/Advent Of Code Day 10-part1.ps1 @@ -0,0 +1,18 @@ +$myinput = get-content .\aocd10input.txt +$myinput = $myinput | %{[int]$_} | Sort-Object +$adapterjoltage = 0 +$differences=@{} +$differences[3]=1 +$endjolts=$myinput[-1]+3 +#write-host $endjolts +for($i=0; $i -lt $myinput.count ; $i++){ + $difference = $myinput[$i] - $adapterjoltage + write-host "Diff: $difference" + if($differences[$difference]){ + $differences[$difference]++ + } else { + $differences[$difference]=1 + } + $adapterjoltage = $myinput[$i] +} +$differences[3] * $differences[1] \ No newline at end of file diff --git a/aocd10input.txt b/aocd10input.txt new file mode 100644 index 0000000..a68e236 --- /dev/null +++ b/aocd10input.txt @@ -0,0 +1,108 @@ +115 +134 +121 +184 +78 +84 +77 +159 +133 +90 +71 +185 +152 +165 +39 +64 +85 +50 +20 +75 +2 +120 +137 +164 +101 +56 +153 +63 +70 +10 +72 +37 +86 +27 +166 +186 +154 +131 +1 +122 +95 +14 +119 +3 +99 +172 +111 +142 +26 +82 +8 +31 +53 +28 +139 +110 +138 +175 +108 +145 +58 +76 +7 +23 +83 +49 +132 +57 +40 +48 +102 +11 +105 +146 +149 +66 +38 +155 +109 +128 +181 +43 +44 +94 +4 +169 +89 +96 +60 +69 +9 +163 +116 +45 +59 +15 +178 +34 +114 +17 +16 +79 +91 +100 +162 +125 +156 +65