Day 10 part 1 done

This commit is contained in:
dan 2020-12-09 23:25:53 -06:00
parent 14e6946eae
commit 12742861c6
2 changed files with 126 additions and 0 deletions

View File

@ -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]

108
aocd10input.txt Normal file
View File

@ -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