You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
498 B

using DelimitedFiles
depths = readdlm("day1input.txt")
diffs = depths[2:end] - depths[1:end-1]
pos_diff_count = size(findall(diffs .> 0), 1)
println("depth increases: ", pos_diff_count, " / ", size(diffs, 1))
window_size = 3
window_sums = [sum(depths[i:i+2]) for i in 1:size(depths, 1)-2]
window_diffs = window_sums[2:end] - window_sums[1:end-1]
pos_wdiff_count = size(findall(window_diffs .> 0), 1)
println("window sum increases: ", pos_wdiff_count,
" / ", size(window_diffs, 1))