summary refs log tree commit diff stats
path: root/2020/day-01/day-01.raku
blob: 7ab6c49b1ed39a6bde320ececf4473f0a2571059 (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 @inputs;
@inputs = "input".IO.lines>>.Int;

while pop @inputs -> $num_1 {
    my Int $diff = 2020 - $num_1;
    for @inputs -> $num_2 {
        say "Part 1: ", $num_2 * $num_1 if $diff == $num_2;
    }
}

@inputs = "input".IO.lines>>.Int;
for @inputs -> $num_1 {
    for @inputs -> $num_2 {
        for @inputs -> $num_3 {
            if 2020 == $num_1 + $num_2 + $num_3 {
                say "Part 2: ", ($num_1 * $num_2 * $num_3);
                exit;
            }
        }
    }
}