blob: ae77c2821001f2ee5d1876c53b06c3eacef0df24 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/bin/env raku
my Int @inputs = "input".IO.lines>>.Int;
{
my Int $larger-than-previous = 0;
for (^@inputs.elems).skip -> $idx {
$larger-than-previous++ if @inputs[$idx] > @inputs[$idx - 1];
}
put "Part 1: ", $larger-than-previous;
}
{
my Int $larger-than-previous = 0;
for (^@inputs.elems).skip(3) -> $idx {
$larger-than-previous++ if @inputs[$idx - 2 .. $idx].sum > @inputs[$idx - 3 .. $idx - 1].sum;
}
put "Part 2: ", $larger-than-previous;
}
|