Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Not sure if my solution counts as a tree, but I expect to need the "filesystem" logic in the future, so I overengineered it.
The input was basically a BFS of a tree of a file system (cd and ls). Naturally most of the solutions ended up as a tree operation I think. I first did that and used a DFS to calculate all the dir sizes. To help debugging I also added a String that prints the tree as the tree command (had fun dealing with that). And then because I’m a performance freak, I used a min heap to process the sizes while walking the input so all the sizes were ordered. For AoC problems I try to use the most data structures and algorithms since usually at work I wouldn’t use much lol. Here my solution https://github.com/aoc-2022/packages/aoc-go/solutions/day_07.go