15 lines
556 B
Julia
15 lines
556 B
Julia
|
include("utils.jl")
|
||
|
|
||
|
input_lines = non_empty_lines("1.data")
|
||
|
integers = map(s->parse(Int, s), input_lines)
|
||
|
|
||
|
"1"
|
||
|
zipped = zip(view(integers, 1:length(integers)-1), view(integers, 2:length(integers)))
|
||
|
result1 = mapreduce(t->t[1] < t[2], +, zipped)
|
||
|
|
||
|
"2"
|
||
|
zipped2 = zip(view(integers, 1:length(integers)-2), view(integers, 2:length(integers)-1), view(integers, 3:length(integers)))
|
||
|
summed = map(t->t[1]+t[2]+t[3], zipped2)
|
||
|
zipped_again = zip(view(summed, 1:length(summed)-1), view(summed, 2:length(summed)))
|
||
|
result2 = mapreduce(t->t[1] < t[2], +, zipped_again)
|