AdventOfCode2020/Advent Of Code Day 10-part1.ps1

18 lines
511 B
PowerShell
Raw Permalink Normal View History

2020-12-09 23:25:53 -06:00
$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]