Last active
December 1, 2022 20:05
-
-
Save msullivan/bda7c6050940c28ae481078c6022b305 to your computer and use it in GitHub Desktop.
advent of code day 1 in edgeql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
# I made an object Input with a data property, which made it easier to | |
# develop this in the CLI. It also works fine to make the input a parameter. | |
input := (select Input filter .day = 1).data, | |
# input := <str>$0, | |
grps := array_unpack(str_split(input[:-1], '\n\n')), | |
sums := (for grp in grps union ( | |
with entries := <int64>array_unpack(str_split(grp, '\n')), | |
select sum(entries) | |
)), | |
select { | |
part_1 := max(sums), | |
part_2 := sum((select sums order by sums desc limit 3)), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment